If y(i) contain 5 values such as 1,2,3,4,5. Then i want to sum all the values with a single command but i can't solve this problem. Please help me out, my code is given below.

1 次查看(过去 30 天)
clc
clear
x=0;
for i=1:5
y(i)=x+i
z=sum(y(i))
end

采纳的回答

the cyclist
the cyclist 2014-6-9
编辑:the cyclist 2014-6-9
y = 1:5;
z = sum(y)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Entering Commands 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by