필터 지우기
필터 지우기

issues with fprintf

조회 수: 2 (최근 30일)
Abra dog
Abra dog 2011년 11월 1일
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

채택된 답변

Grzegorz Knor
Grzegorz Knor 2011년 11월 1일
K = {'text1'; 'text2'};
arrayfun(@(idx)fprintf('blahhh blahh %s blahh bahh\n',K{idx}),1:numel(K))

추가 답변 (1개)

Daniel Shub
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
Grzegorz Knor 2011년 11월 1일
Thanks for the hint. I did not know that it can be done with cell arrays.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Text Data Preparation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by