Index exceeds the number of array elements (1). How can I correct this error?

1 view (last 30 days)
Hi I've got this code that gives me the messages from a variable that are from a mmsi that I want
Msg_mmsi_selected = [];
for i=1:1:L
seq1 = msg_NoMatchAIS1(i);
if linia(13)=='A' && linia(15)=='1'
sequencia = ais_to_bit(linia(15:44));
mmsi= bin2dec(num2str(s_mmsi));
Msg_mmsi_selected = seq1(mmsi_selected); % Here is the line that give me error
and the error I got is
Index exceeds the number of array elements (1).
Is there any problem in the line code that makes me this error. I thought it was because of not named the variable but I did and do not know why I continue having it.
flashpode on 26 Oct 2021
well I am gonna changa the question due to a change of code. That maybe it is easy for me to explain. Lets see, I've got a variable that is num_mmsi_selected that has the number of the mmsi in the position that we find it. So my question is how can I change the number of the mmsi to the number of the cell with find it. Now a example:
Here we can see that in the cells 5 and 6 there is the mmsi so I want to change this number and put 5 and 6 the same with all the lines that have this number. I uploaded the data so you can work easily.

Sign in to comment.

Answers (0)


Find more on Creating and Concatenating Matrices 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!