problem of for loop

1 visualizzazione (ultimi 30 giorni)
mahesh chathuranga
mahesh chathuranga il 9 Set 2013
this is my programme
for k=1:10
x(k)=sin(k)
end
now i want to add all the 10 values together

Risposta accettata

Azzi Abdelmalek
Azzi Abdelmalek il 9 Set 2013
Modificato: Azzi Abdelmalek il 9 Set 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)

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by