n term series using For loop

3 Ansichten (letzte 30 Tage)
marie
marie am 13 Mär. 2013
n=input('enter a value n:');
s=0;
k=1;
for k=<n
s=s+k;
k=k+1;
end
I was trying to change my while loop for this one (for loop) to see if the results were the same but when i type the code it says unexpected matlab operator The code was working for the while loop
  1 Kommentar
Matt J
Matt J am 13 Mär. 2013
In the for loop version, you would remove this line
k=k+1;

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Azzi Abdelmalek
Azzi Abdelmalek am 13 Mär. 2013
It's
for k=1:n

Gilles
Gilles am 13 Mär. 2013

Kategorien

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

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by