average for all looping

1 Ansicht (letzte 30 Tage)
Takim Mustakim
Takim Mustakim am 23 Mai 2022
Kommentiert: Takim Mustakim am 23 Mai 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 ??

Akzeptierte Antwort

David Hill
David Hill am 23 Mai 2022
No loop needed.
average_a=mean(randi(10,1,10))
  3 Kommentare
David Hill
David Hill am 23 Mai 2022
s=0;
for i=1:10
s=s+randi(10);
end
m=s/10;
Takim Mustakim
Takim Mustakim am 23 Mai 2022
thank you bro

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by