Get the time of the messages

조회 수: 4 (최근 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