sum in matlab coding
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
what is the difference between
sum(a(1):a(3)) and sum(a(1:3))?
0 commentaires
Réponse acceptée
DGM
le 12 Fév 2022
Modifié(e) : DGM
le 12 Fév 2022
The first case is summing a linear increasing series between two values stored in a vector. The second is the sum of a subvector within a vector.
a = [5 -10 15 -20]
a(1):a(3) % linear vector from 5 to 20 in steps of 1
a(1:3) % elements 1 through 3 of the vector a
sum(a(1):a(3))
sum(a(1:3))
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Logical 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!