problem of for loop

this is my programme
for k=1:10
x(k)=sin(k)
end
now i want to add all the 10 values together

 Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 9 de Sept. de 2013
Editada: Azzi Abdelmalek el 9 de Sept. de 2013

0 votos

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)

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by