average for all looping

1 次查看(过去 30 天)
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 ??

采纳的回答

David Hill
David Hill 2022-5-23
No loop needed.
average_a=mean(randi(10,1,10))
  3 个评论
David Hill
David Hill 2022-5-23
s=0;
for i=1:10
s=s+randi(10);
end
m=s/10;

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by