How can I found character in a 2D array
Afficher commentaires plus anciens
I have a problem about create a function which is tried to do at each row of a 2D character array there is a string which can have duplicate characters.I had tried to create function called "is_existing" that will accept two inputs one of the inputs arrays An array (say X) with above-given properties, and another 2D character array (say Y) whose number of columns is equal to the number of columns of X. The number of rows of these two arrays can be different. The output will be a column vector whose number of rows is equal to the number of rows of Y. For any row of Y, if there exists a row of X that is composed of a permutation of the string given in this row of Y, the corresponding element of the output vector will be logical 1. Otherwise, it will be logical 0.
----------------------------------------------------------------------------------------------------------------------------------------
I tried this
X=['133ABC36';'V2EL8A3V';'9MEHHET9';'919EY9EN'];
Y=['C3C3C3C3';'631A3B3C';'ETM99MEH'];
rowY=size(Y)(1);
colY=size(Y)(2);
rowX=size(X)(1);
colX=size(X)(2);
test=zeros(rowX,colX);
for i=1:rowY
for j=1:colY
for k=1:rowX
for t=1:colX
if Y(i,j)==X(k,t)
test(k,t)=1;
end
end
end
end
end
I couldn't create a function.It doesn't works like what I want.
5 commentaires
KSSV
le 12 Juin 2020
Read about strcmp, strfind.
Hazar Can Dai
le 12 Juin 2020
Anna Case
le 12 Juin 2020
If you want case-insensitvity, use strcmpi()
Hazar Can Dai
le 12 Juin 2020
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Matrix Indexing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!