problem of for loop

1 Ansicht (letzte 30 Tage)
mahesh chathuranga
mahesh chathuranga am 9 Sep. 2013
this is my programme
for k=1:10
x(k)=sin(k)
end
now i want to add all the 10 values together

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 9 Sep. 2013
Bearbeitet: Azzi Abdelmalek am 9 Sep. 2013
If you mean to sum all the values use
for k=1:10
x(k)=sin(k)
end
out=sum(x)
%or without a for loop
k=1:10
x=sin(k)
out=sum(x)
  1 Kommentar
mahesh chathuranga
mahesh chathuranga am 9 Sep. 2013
thank you very very much

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

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by