more than one input in sprintf
이전 댓글 표시
Hye, I would like to put two argument in sprintf.
I tried:
sprintf('mu=%s ,nu/omega=%s',mu1,q)
but it doesn't work, only the first one is assigned.
댓글 수: 4
Liber-T
2011년 7월 19일
Sean de Wolski
2011년 7월 19일
That also works fine for me.
what does:
class(mu1)
class(q)
return?
Liber-T
2011년 7월 19일
Sean de Wolski
2011년 7월 19일
that is your issue - they're doubles not strings. So you should be using %f or %g in your sprintf statement instead of %s which indicates class char. See both Walter's and my suggestions below.
채택된 답변
추가 답변 (1개)
Walter Roberson
2011년 7월 19일
That should work fine, provided that mu1 and q are both strings already.
Perhaps you want
sprintf('mu=%g, nu/omega=%g\n', mu1, q)
카테고리
도움말 센터 및 File Exchange에서 String에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!