フィルターのクリア

how to convert char to array of string?

2 ビュー (過去 30 日間)
Tejaswini Ramesh
Tejaswini Ramesh 2016 年 8 月 1 日
コメント済み: Tejaswini Ramesh 2016 年 8 月 1 日
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

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 8 月 1 日
name_final = {'PECCalc_tqElFil2_VW_173','PECCtl_bDampCtl_VW_173'}
out=regexp(name_final,'.+(?=.{4})','match','once')
  1 件のコメント
Tejaswini Ramesh
Tejaswini Ramesh 2016 年 8 月 1 日
this works! thank you very much :)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by