Get the time of the messages

6 Ansichten (letzte 30 Tage)
flashpode
flashpode am 22 Okt. 2021
Kommentiert: Jan am 22 Okt. 2021
Hi, I've got a code that gives me the messages that repeat from two different strings. What I want is to get the time from the those messages but when I do it I get an error. Here is the code:
for K = 1:1:N
all_match_AIS = find(msg_AIS1(K) == msg_AIS2); % encontrar mensajes iguales
if isempty(all_match_AIS) %fprintf para escribir datos en un archivo de texto
% fprintf('No hay coincidencias para la linia #%d -> "%s"\n', origi_AIS1(K), msg_AIS1(K)); % '%s' para un string
continue;
end
% fprintf('potencial coincidencia #%d -> "%s", checking times\n', origi_AIS1(K), msg_AIS1(K));
% disp(K), disp(all_match_AIS)
if H1(K)== H2(all_match_AIS)
% crear rango de coincidencia de minutos
complete_match_AIS = all_match_AIS(M1(K) == M2(all_match_AIS) | M1(K) == M2(all_match_AIS) - 1 | M1(K) == M2(all_match_AIS) + 1);% Rango creado +-1 minuto de cada mensaje
msg_match{K} = msg_AIS1(complete_match_AIS);
Time_Matching = Time_AIS1(msg_match(K)) % HERE I GOT THE PROBLEM IMPORTANTE
end
if isempty(complete_match_AIS)
% fprintf('line %#d -> "%s" coincide texto pero no tiempo\n', origi_AIS1(K), msg_AIS1(K));
else
% fprintf ('line %#d -> "%s" coincide tambien el tiempo. Los resultados son:\n', origi_AIS1(K), msg_AIS1(K));
msg_AIS2(complete_match_AIS) %IMPORTANTE
end
end
The problem I got is the next one:
Unable to use a value of type cell as an index.
Error in matlab.internal.datatypes.parenReference_1D (line 12)
data = data(rowIndices);
Error in duration/parenReference (line 19)
obj.millis = parenReference_1D(obj.millis, rowIndices);
Error in CodiVicens (line 41)
Time_Matching = Time_AIS1(msg_match(K))%coger los mensajes de las lineas que han coincidido. IMPORTANTE
Thank you in advance

Antworten (1)

Jan
Jan am 22 Okt. 2021
Try:
Time_Matching = Time_AIS1(msg_match{K}) % curly braces
  2 Kommentare
flashpode
flashpode am 22 Okt. 2021
hey I get this problem:
Unable to use a value of type string as an index.
I do not why but the variable Time_AIS1 is a duration variable, I do not know if it has to be something about it
Jan
Jan am 22 Okt. 2021
The error mesage, that the contents of msg_match{K} is a string. Then you cannot use it for indexing.

Melden Sie sich an, um zu kommentieren.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by