how to convert arrays inside my cell array into cells?
古いコメントを表示
if I have a cell array:
% code
cities =
'city1'
'city2'
'city3'
'city4'
'city5'
I want my cell to include cells that include the strings inside like that
% code
cities =
{1x1 cell}
{1x1 cell}
{1x1 cell}
{1x1 cell}
{1x1 cell}
for example in the 3rd cell inside my cell array there is
% code
{1x1 cell}% inside of it --> 'city3'
without using any kind of loop! (cause I can do it without any real problam with a loop)
2 件のコメント
Image Analyst
2013 年 12 月 29 日
Cells are complicated - why make it even more complicated than it needs to be? If you want you could have cells inside of cells inside of cells inside of cells. But why?
ilona
2013 年 12 月 29 日
採用された回答
その他の回答 (2 件)
Azzi Abdelmalek
2013 年 12 月 29 日
編集済み: Azzi Abdelmalek
2013 年 12 月 29 日
cities ={'city1'
'city2'
'city3'
'city4'
'city5'}
out=cellfun(@(x) {x},cities,'un',0)
out{3}
%or
out=cellfun(@cellstr,cities,'un',0)
3 件のコメント
ilona
2013 年 12 月 29 日
Azzi Abdelmalek
2013 年 12 月 29 日
I don't know how to explain, maybe you should look at
doc cellfun
ilona
2013 年 12 月 29 日
Azzi Abdelmalek
2013 年 12 月 29 日
out=regexp(cities,'.+','match')
カテゴリ
ヘルプ センター および File Exchange で Loops and Conditional Statements についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!