Ismember and ways to implement it

3 vues (au cours des 30 derniers jours)
flashpode
flashpode le 15 Sep 2021
Commenté : flashpode le 15 Sep 2021
Hey,I have two strings where every message from there has an arrival time. I have to compare the Messages from S1 with S2(strings both), as they are very big to compare with ismember I have to do it another way. Compare the first message from S1 with all the messages from S2 that came at the same time or 1 min before and after. Imagine one message from S1 has arrived at 5 min 40 sec. it should be compared with the message from S2 that came from the minut 4:40 and 6:40. The code that gave me the time from each message is:
N = size(AIS1,1)
p = size(AIS2,1)
TimeAIS1 = [];
TimeAIS2 = [];
for i=1:1:N
seq1=AIS1(i);
TimeAIS1 = [TimeAIS1,extractAfter(seq1,strlength(seq1)-4)];
DN = str2double(TimeAIS1);
dur1 = minutes(floor(DN/100)) + seconds(mod(DN,100));
end
for j=1:1:N
seq2=AIS2(j);
TimeAIS2 = [TimeAIS2,extractAfter(seq2,strlength(seq2)-4)];
DN2 = str2double(TimeAIS2);
dur2 = minutes(floor(DN2/100)) + seconds(mod(DN2,100));
end
  7 commentaires
Steven Lord
Steven Lord le 15 Sep 2021
So this message from your first set:
"!AIVDM,2,1,3,B,54hG=R82FP2e`LQc:208E8<v1HuT4LE:2222220U1pI446b;070PDPiC3kPH,0*720000"
would be compared with each of these messages from your second set:
"!AIVDM,1,1,,A,13ErMfPP00P9rFpGasc>4?wn2802,0*070000"
"!AIVDM,1,1,,B,13FMMd0P0009o1jGapD=5gwl06p0,0*780000"
"!AIVDM,1,1,,A,4028ioivDfFss09kDvGag6G0080D,0*790000"
"!AIVDM,1,1,,A,D028ioj<Tffp,0*2C0000"
"!AIVDM,1,1,,B,19NS@=@01qP9tp4GQkJ0bh`200SP,0*780000"
"!AIVDM,1,1,,B,137FrD0v2u0:=4pGS;s6u5On00SJ,0*000000"
"!AIVDM,1,1,,A,4028jJ1vDfG0009cIVGdh2?0280S,0*400000"
"!AIVDM,1,1,,B,H3GQ9khl4LLTF0l5T0000000000,2*070001"
"!AIVDM,1,1,,A,H33mw2Q>uV0luHTpN3800000000,2*080001"
"!AIVDM,1,1,,B,13FtuD?P00P9tuDGbFw4Jgv40L1f,0*030002"
In this case that first message is much longer than any of the messages from the second set, so there's no possibility of a match. Correct?
The second message in the first set also gets compared with the whole second set:
"!AIVDM,2,2,3,B,88888888880,2*240000"
By inspection, there's no match. A quick scan suggests the first message from the first set that matches is the 8th:
"!AIVDM,1,1,,A,4028ioivDfFss09kDvGag6G0080D,0*790000"
This matches the third message from the second set. So what do you want the output to look like? If you're emulating ismember you'd want the first seven elements of the first output to be false and the 8th true? For the second output you'd want the first seven elements to be 0 and the 8th 3?
flashpode
flashpode le 15 Sep 2021
Yes, thats it using inmember but with the restriction that I explained of the last 4 digits

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by