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!