how to convert char to array of string?

3 Ansichten (letzte 30 Tage)
Tejaswini Ramesh
Tejaswini Ramesh am 1 Aug. 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

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 1 Aug. 2016
name_final = {'PECCalc_tqElFil2_VW_173','PECCtl_bDampCtl_VW_173'}
out=regexp(name_final,'.+(?=.{4})','match','once')

Weitere Antworten (0)

Kategorien

Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by