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

MATLAB: Create a 1xn vector consisting of random integers between 0 and 2000. Th

ID: 638566 • Letter: M

Question

MATLAB:

Create a 1xn vector consisting of random integers between 0 and 2000. These values will be assigned units of feet per second. The 1xn vector will be part of an nx3 array where the first column is feet per second (ft/s); the second column is inches per second (in/s); and the third column is (cm/s). The program should prompt the user for the value of n. Your program should include a for loop with a print statement that will print n lines as follows

XXX ft/s= YYY in/s = ZZZ cm/s

XXX ft/s= YYY in/s = ZZZ cm/s

XXX ft/s= YYY in/s = ZZZ cm/s

Explanation / Answer

n=input('enter number of elements ');
r=randi([0 2000],1,n);
output=zeros(n,3);
output(:,1)=r';
output(:,2)=r'*12;
output(:,3)=r'*30.48;

for i=1:n
fprintf(' %f ft/s= %f in/s = %f cm/s ',output(i,1),output(i,2),output(i,3));
pause(0.1);
end