problem of for loop

1 view (last 30 days)
mahesh chathuranga
mahesh chathuranga on 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

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 9 Sep 2013
Edited: Azzi Abdelmalek on 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)

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!