Index must not exceed 10, but why???

2 Ansichten (letzte 30 Tage)
Brenno Selli
Brenno Selli am 27 Feb. 2023
Kommentiert: Jan am 27 Feb. 2023
I'm in trouble with this error
"Index exceeds the number of array elements. Index must not exceed 10
Error in ESTATISTICAS_DESCRITIVAS (line 51)
tempo(:,j) = 0:dt(j):(length(road_x1)-1)*dt(j) ;"
the code that I'm using right now is:
dt = transpose(dx1./v); %making it a 10x1 array
m = length(dt);
n = length(verticalperf1);
temp0 = zeros(m,n) ;
for j = 1:n
tempo(:,j) = 0:dt(j):(length(road_x1)-1)*dt(j) ;
end
verticalperf1 now is a vector 1x60001, I used this vector just because sometimes the length may change, using length(verticalperf1) makes the code run nicely and good all times.
the code results in a array (60001x10) called "tempo", its completely okay, the vallues are good and acurate, it works but the error is not allowing me to proceed, theres any way that I can solve it or just skip this error??

Akzeptierte Antwort

Torsten
Torsten am 27 Feb. 2023
Verschoben: Torsten am 27 Feb. 2023
If dt is an array of length 10, then "n" in the loop "for j = 1:n" must be <= 10 since you try to access dt(j).
Is this the case ? My guess is, no.
  3 Kommentare
Image Analyst
Image Analyst am 27 Feb. 2023
Bearbeitet: Image Analyst am 27 Feb. 2023
What is dt, dx1, and v?
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:
save('anwers.mat', 'dt', 'verticalperf1', 'dx1', 'v')
then attach answers.mat with the paperclip icon.
Jan
Jan am 27 Feb. 2023
@Brenno Selli: "I tryed it" - you tried what? Torsten has explained, what the error is. So what did you change in your code?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by