Index in position 2 exceeds array bounds. Error in line 20

2 vues (au cours des 30 derniers jours)
Arup Barua
Arup Barua le 17 Déc 2019
Commenté : Walter Roberson le 24 Déc 2019
  3 commentaires
Adam Danz
Adam Danz le 20 Déc 2019
And what is the size of A when there is an error?
Arup Barua
Arup Barua le 20 Déc 2019
I have total 947(Nspec) files. The file name is 'spec1.dat' up to 'spec947.dat'. Each file consists of two colums with floating numbers. I am running this code in MacOs Catalina and having this error. But the same code runs fine in windows!! I am new to mac and the matlab version i am using is R2019b (both Windows and Mac).

Connectez-vous pour commenter.

Réponses (2)

Vinai Datta Thatiparthi
Vinai Datta Thatiparthi le 23 Déc 2019
Hey Arup,
"Index in position 2 exceeds array bounds" indicates that there's a mismatch in array dimensions, you are probably trying to access a data point or memory that doesn't exist. You are probably trying to index into an array, but are using indices that exceed the size of the array.
Refer to the Documentation link on Debugging Tools in MATLAB, it may be of help to you.
Hope this helps!

Walter Roberson
Walter Roberson le 23 Déc 2019
You are using fscanf() on a file you opened for writing ('w') When you opened the file for writing, the entire content of the file would have been deleted, so there is nothing left in it to read.
  2 commentaires
Arup Barua
Arup Barua le 24 Déc 2019
I have changed it to 'r' but still the same. The problem is the code run just fine in windows but gives this error in MacOS.
Walter Roberson
Walter Roberson le 24 Déc 2019
It is difficult for us to debug without a copy of the code (not just an image of code) and enough data files to be able to run to the problem.

Connectez-vous pour commenter.

Catégories

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

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by