How to use the SUM() function..?
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
paul
am 5 Okt. 2022
Verschoben: Steven Lord
am 5 Okt. 2022
Hello,
I must be doing something very stupid here, as I can't get the sum() function to work at all;
X = [0 0.5 1 1.5 2 2.5]
sum(X(1,:))
From what I've read, this should sum all the element of row 1 of the matrix X and return a numerical result, but when I try it, I get the error:
Array indices must be positive integers or logical values.
Can anybody tell me what I'm doing wrong, please?
Thanks,
Paul
0 Kommentare
Akzeptierte Antwort
Bruno Luong
am 5 Okt. 2022
You overshadow sum function
make sure to run
clear sum
before runing your code
2 Kommentare
Weitere Antworten (1)
Torsten
am 5 Okt. 2022
Did you create a MATLAB function with name sum.m ? If yes, rename it.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!