add result to next entry of the column

1 vue (au cours des 30 derniers jours)
aditi
aditi le 9 Avr 2014
Commenté : aditi le 9 Avr 2014
I have a column as:
1
2
3
4
5
and so on....
I have to add a no. 25 to first enrty and then add the result to next entry...then this result to the 3rd entry...and so on...i.e in above case
25 + 1= 26
26 + 2 = 28
28 + 3 = 31
31+ 4 = 35
and so on...
plz help me....

Réponse acceptée

Chandrasekhar
Chandrasekhar le 9 Avr 2014
Modifié(e) : Chandrasekhar le 9 Avr 2014
if a is your initial array then
sum = 25;
for i = 1:length(a)
sum = sum+a(i);
end
  1 commentaire
aditi
aditi le 9 Avr 2014
thanks a lot akshata.... :)

Connectez-vous pour commenter.

Plus de réponses (1)

Azzi Abdelmalek
Azzi Abdelmalek le 9 Avr 2014
out=25+cumsum(1:6)

Catégories

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

Community Treasure Hunt

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

Start Hunting!

Translated by