problem of for loop
1 view (last 30 days)
Show older comments
this is my programme
for k=1:10
x(k)=sin(k)
end
now i want to add all the 10 values together
0 Comments
Accepted Answer
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)
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!