How to convert a list in the variable into a cell array

I have a list of names set as a variable and I would like to know how you can make that list into a cell array without typing each one out
for example my list
val=
ABC
DEF
GHK
can i make/convert that into an array without typing each one out like list={'ABC','DEF','GHK'} thanks

回答 (2 件)

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 3 月 24 日
編集済み: Azzi Abdelmalek 2013 年 3 月 24 日

0 投票

out=cellstr(reshape('A':'I',[],3)')'

3 件のコメント

Jayden Deng
Jayden Deng 2013 年 3 月 24 日
but the thing is, i need to make very large variables into arrays and they do not have a pattern like A to I so how can i turn it into an array without writing out each one
Jayden Deng
Jayden Deng 2013 年 3 月 24 日
also could i use the tabulate function to count as well?
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 3 月 24 日
編集済み: Azzi Abdelmalek 2013 年 3 月 24 日
If there is not any pattern, you have to enter them manually, then use reshape function

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

Walter Roberson
Walter Roberson 2013 年 3 月 25 日

0 投票

If the variable is currently a char array, then use cellstr() to convert to a cell array.

カテゴリ

ヘルプ センター および File ExchangeCell Arrays についてさらに検索

タグ

質問済み:

2013 年 3 月 24 日

Community Treasure Hunt

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

Start Hunting!

Translated by