more than one input in sprintf
Ältere Kommentare anzeigen
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 Kommentare
Liber-T
am 19 Jul. 2011
Sean de Wolski
am 19 Jul. 2011
That also works fine for me.
what does:
class(mu1)
class(q)
return?
Liber-T
am 19 Jul. 2011
Sean de Wolski
am 19 Jul. 2011
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.
Akzeptierte Antwort
Weitere Antworten (1)
Walter Roberson
am 19 Jul. 2011
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)
Kategorien
Mehr zu String finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!