Quick question about the loop

1 次查看(过去 30 天)
JK
JK 2014-10-19
回答: Jan 2014-10-19
How do I collect values that were done through the loop?
For example,
M=10:40
for i=0:30;
i=i+1;
A=10+M(i);
end
and the answer just comes out as A=50, instead of A=20:50. What would I do in order to collect the 30 values as matrix?

采纳的回答

Andrejus
Andrejus 2014-10-19
编辑:Andrejus 2014-10-19
try this:
M=10:40
for i=0:30;
i=i+1;
A(i)=10+M(i);
end
  1 个评论
Jan
Jan 2014-10-19
Do not increase the value of the loop copunter inside loop.

请先登录,再进行评论。

更多回答(1 个)

Jan
Jan 2014-10-19
M = 10:40
A = M + 10;

类别

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

标签

Community Treasure Hunt

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

Start Hunting!

Translated by