Index in position 2 exceeds array bounds. Error in line 20
Show older comments

3 Comments
Image Analyst
on 20 Dec 2019
What is the size of data, before you get ot line 20?
Adam Danz
on 20 Dec 2019
And what is the size of A when there is an error?
Arup Barua
on 20 Dec 2019
Answers (2)
Vinai Datta Thatiparthi
on 23 Dec 2019
0 votes
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.
Hope this helps!
Walter Roberson
on 23 Dec 2019
0 votes
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 Comments
Arup Barua
on 24 Dec 2019
Walter Roberson
on 24 Dec 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.
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!