Effacer les filtres
Effacer les filtres

Index must not exceed 10, but why???

2 vues (au cours des 30 derniers jours)
Brenno Selli
Brenno Selli le 27 Fév 2023
Commenté : Jan le 27 Fév 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??

Réponse acceptée

Torsten
Torsten le 27 Fév 2023
Déplacé(e) : Torsten le 27 Fév 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 commentaires
Image Analyst
Image Analyst le 27 Fév 2023
Modifié(e) : Image Analyst le 27 Fév 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 le 27 Fév 2023
@Brenno Selli: "I tryed it" - you tried what? Torsten has explained, what the error is. So what did you change in your code?

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by