Filter löschen
Filter löschen

Quick question about the loop

1 Ansicht (letzte 30 Tage)
JK
JK am 19 Okt. 2014
Beantwortet: Jan am 19 Okt. 2014
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?

Akzeptierte Antwort

Andrejus
Andrejus am 19 Okt. 2014
Bearbeitet: Andrejus am 19 Okt. 2014
try this:
M=10:40
for i=0:30;
i=i+1;
A(i)=10+M(i);
end
  1 Kommentar
Jan
Jan am 19 Okt. 2014
Do not increase the value of the loop copunter inside loop.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Jan
Jan am 19 Okt. 2014
M = 10:40
A = M + 10;

Kategorien

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

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by