Effacer les filtres
Effacer les filtres

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.

2 vues (au cours des 30 derniers jours)
clc
clear
x=0;
for i=1:5
y(i)=x+i
z=sum(y(i))
end

Réponse acceptée

the cyclist
the cyclist le 9 Juin 2014
Modifié(e) : the cyclist le 9 Juin 2014
y = 1:5;
z = sum(y)

Plus de réponses (0)

Catégories

En savoir plus sur Get Started with MATLAB dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by