Compare 2 string documents

조회 수: 4 (최근 30일)
flashpode
flashpode 2021년 7월 14일
답변: Sulaymon Eshkabilov 2021년 7월 14일
Hi, I want to compare 2 strings and see if there are messages that are the same. i want to compare de first line with all the others from the other document and put it in to another string. The string are AIS1 19000 X 1 and AIS2 13000 X 1.
I've coded a little bit but i have an error of matrix dimensions must agree.
M_conjunt = [];
M_D_AIS1 = [];
M_D_AIS2 = [];
N=size(AIS1,1)
P=size(AIS2,1)
for i=1:1:N
for j=1:1:P
seq1=AIS1(i);
seq2=AIS2(j);
linia1=convertStringsToChars(seq1);
linia2=convertStringsToChars(seq2);
if AIS1 == AIS2
M_conjunt = [M_conjunt,i];
end
end
end
I do not undestand why do I continue getting this problem
  댓글 수: 3
flashpode
flashpode 2021년 7월 14일
My output is M_conjunt if it repeats and if it not repeats M_D_AIS1 for messages in AIS1 and M_D_AIS2 for messages in AIS2.
David Hill
David Hill 2021년 7월 14일
Show us an example of your output based on your input.

댓글을 달려면 로그인하십시오.

답변 (1개)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021년 7월 14일
The err is here:
if AIS1 == AIS2 % ERR
% Corrected one:
if AIS1(i) == AIS2(i)
Note that sizes of AIS1 and AIS2 are to match.

카테고리

Help CenterFile Exchange에서 Dialog Boxes에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by