Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This code would ask the user to enter a number between 1 and 5, and store the in

ID: 3562189 • Letter: T

Question

This code would ask the user to enter a number between 1 and 5, and store the input number in the some_num variable. You may be wondering what the single quotes are. In MATLAB, single quotes denote a string. A string is a sequence of characters, such as dog, and ate my homework!. For the purposes of this lab, you can consider a string to simply represent text.

1) Based on the information above, write the MATLAB code to ask the user to enter a velocity in m/s. Be sure to store the input in a variable that has a fitting name.

Explanation / Answer

% you can directly store the data from the user or can ask him how many data are there.
% pre-defining the number of elements will increase efficiency.

size=input('enter number of elements'); % ask the user to give the number of elements he is going to enter

a=zeros(1,5); %create an array with that size.

for i=1:size
a(i)=input('enter the data ');
end

%to display the data

disp('you have entered');
disp(a)