Display the content of the cell array
15 ビュー (過去 30 日間)
古いコメントを表示
Gopalakrishnan venkatesan
2016 年 8 月 18 日
コメント済み: Gopalakrishnan venkatesan
2016 年 8 月 18 日
I have a cell array a = {'Ford' , 'AUDI'}
I want to display content in the cell array
i tried using a = sprintf('The selected cars are: %s', a{:})
disp(a)
i am getting the output as ''The selected cars are: FordThe selected cars are: AUDI''
But i should get the output as ''The selected cars are: Ford, AUDI
Where did i went wrong?
Thank you
0 件のコメント
採用された回答
Stephen23
2016 年 8 月 18 日
編集済み: Stephen23
2016 年 8 月 18 日
>> sprintf('The selected cars are:%s',sprintf(' %s,',a{:}))
ans = The selected cars are: Ford, AUDI,
Or if you do not want the trailing comma, then in two steps:
>> tmp = sprintf(' %s,',a{:});
>> sprintf('The selected cars are:%s',tmp(1:end-1))
ans = The selected cars are: Ford, AUDI
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Java Package Integration についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!