get the last for digits of the messages and create another array with them

i asked before how to get the last 4 digits of a certain message but what i want to do is to create a string with those numbers here is the code that I hace and an exemple of the type of message:
TimeAIS1 = [];
for i=1:1:N
seq1=AIS1(i)
linia=convertStringsToChars(seq1);
linia(end-3:end)
TimeAIS1 = [TimeAIS1,linia(end-3:end)];
end
TimeAIS1([TimeAIS1],:) = [];
My result is a char and what i want is a string with those numbers. the type of message is the following:
"!AIVDM,2,1,3,B,54hG=R82FP2e`LQc:208E8<v1HuT4LE:2222220U1pI446b;070PDPiC3kPH,0*720000"
Thank you so much

 採用された回答

Cris LaPierre
Cris LaPierre 2021 年 9 月 14 日
They are characters because you convert your string to a character array. Ether convert the result back to a string using string, or better yet, use a function designed to operate on strings like extractAfter.
AIS1(1) = "!AIVDM,2,1,3,B,54hG=R82FP2e`LQc:208E8<v1HuT4LE:2222220U1pI446b;070PDPiC3kPH,0*720000";
TimeAIS1 = [];
for i=1:1
seq1=AIS1(i);
TimeAIS1 = [TimeAIS1,extractAfter(seq1,strlength(seq1)-4)]
end
TimeAIS1 = "0000"

3 件のコメント

flashpode
flashpode 2021 年 9 月 14 日
So if AIS1 is a string of 17200x1 its gonna work??
Cris LaPierre
Cris LaPierre 2021 年 9 月 14 日
It should be rather easy to run it and see.
flashpode
flashpode 2021 年 9 月 14 日
yeah Thank you so much

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeDates and Time についてさらに検索

質問済み:

2021 年 9 月 14 日

コメント済み:

2021 年 9 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by