average for all looping

1 view (last 30 days)
Takim Mustakim
Takim Mustakim on 23 May 2022
Commented: Takim Mustakim on 23 May 2022
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

David Hill
David Hill on 23 May 2022
No loop needed.
average_a=mean(randi(10,1,10))
  3 Comments
David Hill
David Hill on 23 May 2022
s=0;
for i=1:10
s=s+randi(10);
end
m=s/10;
Takim Mustakim
Takim Mustakim on 23 May 2022
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!