issues with fprintf
2 ビュー (過去 30 日間)
古いコメントを表示
I'm trying to list out something in fprintf how do i do it one at a time? Example: fprintf('blahhh blahh %s blahh bahh\n',K) K = text1 text2 I want it to say blahh blahh text1 blahh blahh and then in another row under it blahh blahh text 2 blahh blahh
0 件のコメント
採用された回答
Grzegorz Knor
2011 年 11 月 1 日
K = {'text1'; 'text2'};
arrayfun(@(idx)fprintf('blahhh blahh %s blahh bahh\n',K{idx}),1:numel(K))
0 件のコメント
その他の回答 (1 件)
Daniel Shub
2011 年 11 月 1 日
fprintf is vectorized ...
K = {'text1'; 'text2'};
fprintf('blahhh blahh %s blahh bahh\n',K{:})
gives the same results as the accepted answer.
1 件のコメント
Grzegorz Knor
2011 年 11 月 1 日
Thanks for the hint. I did not know that it can be done with cell arrays.
参考
カテゴリ
Help Center および File Exchange で Text Data Preparation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!