Effacer les filtres
Effacer les filtres

combine two cell in one string and compare it with pattern

3 vues (au cours des 30 derniers jours)
ayman mounir
ayman mounir le 27 Juil 2019
Commenté : ayman mounir le 28 Juil 2019
ma.JPG
For exaple If I want to combine two cell in one character or string and seperate between them by a space this should be as ' 20Ah CATL'
then I have a file name I want to compere it with to check does the file name contains one of them or not. to be more clear example:
finle name : ''Hallo_CATL'' and my string is ' 20Ah CATL' does the file name contain CATL or 20Ah.
Thanks in advance

Réponse acceptée

madhan ravi
madhan ravi le 27 Juil 2019
>> c = {'Z20','20Ah','CATL'};
>> v = strcat(c(2),{' '},c(3))
v =
1×1 cell array
{'20Ah CATL'}
>> filename = "Hallo_CATL";
>> w = regexp(filename,c(2:3),'match')
w =
1×2 cell array
{0×0 string} {["CATL"]}
>> contains_atleast_one = nnz(~cellfun('isempty',w)) >= 1 % 1 means true , false otherwise
contains_atleast_one =
logical
1
>>

Plus de réponses (1)

KSSV
KSSV le 27 Juil 2019
Read about strcat, strjoin

Catégories

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

Produits


Version

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by