How can I solve this problem?
Show older comments
I got a loop that reads the messages and gets the information of these messages, while looping it stops due to a common error. How can I solve it. My code is:
for i=1:1:P
seq1 = AIS2(i);
linia=convertStringsToChars(seq1);
if linia(13)=='A' && linia(15)=='1'
sequencia = ais_to_bit(linia(15:44));
s_longitud=sequencia(62:89);
longitud = bin2dec(num2str(s_longitud))/600000; lon1 = [lon1, longitud];
s_latitud=sequencia(90:116);
latitud = bin2dec(num2str(s_latitud))/600000; lat1 = [lat1, latitud];
pos_lat = 1:numel(lat1); value_lat = lat1(lat1>50); index1 = pos_lat(lat1>50);
lat1(index1) = [];lon1(index1) = [];
pos_lon = 1:numel(lon1); value_lon = lon1(lon1>3); index2 = pos_lon(lon1>3);
lat1(index2) = []; lon1(index2) = [];
end
end
and the error I get is:
Index exceeds the number of array elements. Index must not exceed 35.
Error in NewCode (line 37)
sequencia = ais_to_bit(linia(15:44));
I understand the problem as I have read about it in other posts, how could I program it as if it happens with a message ust delete this message and continue with the loop?
Accepted Answer
More Answers (0)
Categories
Find more on Geographic Plots 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!