필터 지우기
필터 지우기

if I want to save a formatted string to memory, but not to print it out, what command(s) would I use?

조회 수: 4 (최근 30일)
fprintf, sprintf, disp, or echo?
I know that fprintf and sprintf create formatted strings and disp does print out so I'm confused on what the answer would actually be.
thank you!

답변 (1개)

Star Strider
Star Strider 2015년 8월 14일
I would save the output of sprintf to a cell array:
For example:
for k1 = 1:5
out{k1,:} = sprintf('This is iteration #%d', k1);
end
Experiment to get the result you want.
  댓글 수: 1
Star Strider
Star Strider 2015년 8월 14일
I did the second originally, but changed it to the first because it then becomes a column vector, and it was easier to read it and verify that it works. The code works either way.

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

카테고리

Help CenterFile Exchange에서 String Parsing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by