format short
datasave=[];
for i=1:10
a=randi(10);
datasave=[i a];
end
display(a)
how to looking for average a for all loop i ??

 Accepted Answer

No loop needed.
average_a=mean(randi(10,1,10))

3 Comments

i using looping with my real script and i want to looking for average for all looping
s=0;
for i=1:10
s=s+randi(10);
end
m=s/10;
thank you bro

Sign in to comment.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Products

Release

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!