Index exceeds matrix dimensions

3 Ansichten (letzte 30 Tage)
Leonardo Mutti
Leonardo Mutti am 22 Okt. 2016
Beantwortet: Star Strider am 22 Okt. 2016
Hello, I noticed that Matlab was returning the error "Index exceeds matrix dimensions" when running this default script:
%%Sum of Vector Elements
% Create a vector and compute the sum of its elements.
% Copyright 2015 The MathWorks, Inc.
A = 1:10;
S = sum(A);
How can I fix that? Thanks in advance!
  1 Kommentar
KSSV
KSSV am 22 Okt. 2016
According to me it should not throw any error...

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Star Strider
Star Strider am 22 Okt. 2016
In your Command Window, type:
which sum -all
If the first on the list of results is:
sum is a variable.
you have your answer.
The ‘fix’ is to rename your ‘sum’ variable to something else that makes sends in the context of your code, for example ‘sum_v’.

Weitere Antworten (0)

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by