Get the time of the messages

3 次查看(过去 30 天)
flashpode
flashpode 2021-10-22
评论: Jan 2021-10-22
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

回答(1 个)

Jan
Jan 2021-10-22
Try:
Time_Matching = Time_AIS1(msg_match{K}) % curly braces
  2 个评论
flashpode
flashpode 2021-10-22
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 2021-10-22
The error mesage, that the contents of msg_match{K} is a string. Then you cannot use it for indexing.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by