matlabprintfcommand-window

Print in Command Window without 'ans = ' in matlab?


When I use sprintf, the results show like this :

sprintf('number=%d %d %d',a,b,c)
sprintf('or %d',h)  

ans = 

number= 5 4 2

ans =

or 2

How can I display the results without ans = obstructing them ?


Solution

  • You can use fprintf instead of sprintf. Remember to put a newline \n at the end of your strings.