Borrar filtros
Borrar filtros

how to convert char to array of string?

2 visualizaciones (últimos 30 días)
Tejaswini Ramesh
Tejaswini Ramesh el 1 de Ag. de 2016
Comentada: Tejaswini Ramesh el 1 de Ag. de 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

Respuesta aceptada

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

Más respuestas (0)

Categorías

Más información sobre Data Type Conversion en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by