Effacer les filtres
Effacer les filtres

how to convert char to array of string?

2 vues (au cours des 30 derniers jours)
Tejaswini Ramesh
Tejaswini Ramesh le 1 Août 2016
Commenté : Tejaswini Ramesh le 1 Août 2016
I have a list of signals named name_final = 'PECCalc_tqElFil2_VW_173','PECCtl_bDampCtl_VW_173' etc..(58 signals) store in the form of cell. I want to delete the last 4 characters (_173) from these names and store it in the form of array. So I use for loop but for some reason it is giving an error stating "In an assignment A(:) = B, the number of elements in A and B must be the same." ( without the loop this codes runs successfully) How do I get these signals stored as array so that it is easy for me to copy? please help.
for r = 1:length(name_final) % name_final is cell type
name1 = name_final(r);
qq = cell2mat(name1); % qq is in the type char
name_new(r) = qq(1:end-4); %name_new is also of type char
end

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 1 Août 2016
name_final = {'PECCalc_tqElFil2_VW_173','PECCtl_bDampCtl_VW_173'}
out=regexp(name_final,'.+(?=.{4})','match','once')
  1 commentaire
Tejaswini Ramesh
Tejaswini Ramesh le 1 Août 2016
this works! thank you very much :)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Data Type Conversion 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