changes of data

9 ビュー (過去 30 日間)
Nuno Fernandes
Nuno Fernandes 2011 年 7 月 25 日
hi everyone
i have something like this
a=C3;A2/C3;C7;C9;A5/E1 and with this
b=regexp(a,';','split') i get this:
'C3' 'A2/C3' 'C7' 'C9' 'A5/E1'
Now the question:
How can i passa from this 'C3' 'A2/C3' 'C7' 'C9' 'A5/E1' to something like a matrix which has in the first line 'C3', second line 'A2/C3', third line 'C7'...
Any ideas?

採用された回答

Nathan Greco
Nathan Greco 2011 年 7 月 25 日
You would not be able to use a matrix, as matrices can only contain the same data types (all numerical or all character arrays) and must have rectangular dimensions (without empty spaces). You can't match up the columns of 'C3' and 'A2/C3', for example, because the latter has 5 characters (5 columns) while the first has 2. Use a cell array instead.
To get a column rather than a row from your output, transpose your b:
a='C3;A2/C3;C7;C9;A5/E1';
b=regexp(a,';','split')'
b will then become a 5x1 cell array.
-Nathan
  1 件のコメント
Nuno Fernandes
Nuno Fernandes 2011 年 7 月 25 日
thanks

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

その他の回答 (1 件)

Oleg Komarov
Oleg Komarov 2011 年 7 月 25 日
  1 件のコメント
Nuno Fernandes
Nuno Fernandes 2011 年 7 月 25 日
thanks:)

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

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by