please answer Write a short MATLAB Program that generates a plot: Use MATLAB\'s
ID: 2994943 • Letter: P
Question
please answer
Explanation / Answer
%we create a for loop with a large control variable n
%and exit the loop when counter is greater then 0.03
%start%
n=100000;%increase n if loop does not take 0.03 seconds on your computer.
tic;
for i=1:n
r(i)=rand;% random number array
s(i)=sum(r);%sum array
m(i)=mean(r);% mean array
std(i)=std(r);% standard deviation array
counter=toc;% elapsed time
t(i)=counter;% elapsed time array
if(counter>0.03)
break;
end
end
plot(t,r)
title('Time measure in MATLAB');
xlabel('elapsed time in second');
ylabel('Random Number');
%end%
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.