<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/242965</link>
    <title>MATLAB Central Newsreader - Help using &quot;disp&quot;</title>
    <description>Feed for thread: Help using &quot;disp&quot;</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Fri, 23 Jan 2009 09:24:02 -0500</pubDate>
      <title>Help using &quot;disp&quot;</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/242965#623388</link>
      <author>Daniel Eliasson</author>
      <description>Hello&lt;br&gt;
&lt;br&gt;
I have done a calcualtion and I get this&lt;br&gt;
&lt;br&gt;
ans=&lt;br&gt;
&lt;br&gt;
11.3&lt;br&gt;
&lt;br&gt;
But I want it to say&lt;br&gt;
&lt;br&gt;
The answer is: 11.3&lt;br&gt;
&lt;br&gt;
How do I do that with the disp function?&lt;br&gt;
&lt;br&gt;
Thanks</description>
    </item>
    <item>
      <pubDate>Fri, 23 Jan 2009 09:30:04 -0500</pubDate>
      <title>Re: Help using &quot;disp&quot;</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/242965#623391</link>
      <author>P </author>
      <description>&quot;Daniel Eliasson&quot; &amp;lt;danielel@kth.se&amp;gt; wrote in message &amp;lt;glc2bi$3ee$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hello&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I have done a calcualtion and I get this&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; ans=&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; 11.3&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; But I want it to say&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; The answer is: 11.3&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; How do I do that with the disp function?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks&lt;br&gt;
&lt;br&gt;
I come from a C background so I always do this&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
ans = 11.3;&lt;br&gt;
fprintf('The answer is: %3.1f\n', ans);</description>
    </item>
    <item>
      <pubDate>Fri, 23 Jan 2009 10:09:02 -0500</pubDate>
      <title>Re: Help using &quot;disp&quot;</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/242965#623402</link>
      <author>Daniel Eliasson</author>
      <description>&quot;P&quot; &amp;lt;pyjunk.nospam@shaw.ca&amp;gt; wrote in message &amp;lt;glc2ms$pgd$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;Daniel Eliasson&quot; &amp;lt;danielel@kth.se&amp;gt; wrote in message &amp;lt;glc2bi$3ee$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; Hello&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; I have done a calcualtion and I get this&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; ans=&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; 11.3&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; But I want it to say&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; The answer is: 11.3&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; How do I do that with the disp function?&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Thanks&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I come from a C background so I always do this&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; ans = 11.3;&lt;br&gt;
&amp;gt; fprintf('The answer is: %3.1f\n', ans);&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Thanks, but sometimes it gives &quot;The answer is: 0.0&quot; even if its not 0&lt;br&gt;
my example:&lt;br&gt;
&lt;br&gt;
I write this&lt;br&gt;
UtBrd=Bredning*InBrd&lt;br&gt;
fprintf('Wu width: %3.1f\n', UtBrd);&lt;br&gt;
&lt;br&gt;
and this happens&lt;br&gt;
UtBrd=&lt;br&gt;
0.0309&lt;br&gt;
&lt;br&gt;
Wu Width: 0.0&lt;br&gt;
&lt;br&gt;
Is there something with the decimals?</description>
    </item>
    <item>
      <pubDate>Fri, 23 Jan 2009 10:14:26 -0500</pubDate>
      <title>Re: Help using &quot;disp&quot;</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/242965#623404</link>
      <author>Justus Skorps</author>
      <description>On 23 Jan., 11:09, &quot;Daniel Eliasson&quot; &amp;lt;danie...@kth.se&amp;gt; wrote:&lt;br&gt;
&amp;gt; &quot;P&quot; &amp;lt;pyjunk.nos...@shaw.ca&amp;gt; wrote in message &amp;lt;glc2ms$pg...@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &quot;Daniel Eliasson&quot; &amp;lt;danie...@kth.se&amp;gt; wrote in message &amp;lt;glc2bi$3e...@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Hello&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; I have done a calcualtion and I get this&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; ans=&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; 11.3&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; But I want it to say&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; The answer is: 11.3&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; How do I do that with the disp function?&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Thanks&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; I come from a C background so I always do this&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; ans = 11.3;&lt;br&gt;
&amp;gt; &amp;gt; fprintf('The answer is: %3.1f\n', ans);&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Thanks, but sometimes it gives &quot;The answer is: 0.0&quot; even if its not 0&lt;br&gt;
&amp;gt; my example:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; I write this&lt;br&gt;
&amp;gt; UtBrd=Bredning*InBrd&lt;br&gt;
&amp;gt; fprintf('Wu width: %3.1f\n', UtBrd);&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; and this happens&lt;br&gt;
&amp;gt; UtBrd=&lt;br&gt;
&amp;gt; 0.0309&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Wu Width: 0.0&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Is there something with the decimals?&lt;br&gt;
&lt;br&gt;
perhaps you should look in matlab help what the fprintf parameters&lt;br&gt;
do...</description>
    </item>
    <item>
      <pubDate>Fri, 23 Jan 2009 10:32:01 -0500</pubDate>
      <title>Re: Help using &quot;disp&quot;</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/242965#623406</link>
      <author>P </author>
      <description>Hi again,&lt;br&gt;
&lt;br&gt;
fprintf is very powerful but it does sometime to get use to syntax.&lt;br&gt;
&lt;br&gt;
The magic format string '%3.1f' means 3 things&lt;br&gt;
&lt;br&gt;
1. 3 is Field Width, 'A digit string specifying the minimum number of digits to be printed'&lt;br&gt;
2. 1 is Precision, 'A digit string including a period (.) specifying the number of digits to be printed to the right of the decimal point'&lt;br&gt;
3. f implies fixed-point notation.&lt;br&gt;
&lt;br&gt;
So yes you need to change the 1 to get to the other decimal. The %x.y formatting allows you to line up strings very nicely.&lt;br&gt;
&lt;br&gt;
a=101&lt;br&gt;
b=0.00001&lt;br&gt;
fprintf('THIS IS %10.5f\n',a)&lt;br&gt;
fprintf('THIS IS %10.5f\n',b)</description>
    </item>
    <item>
      <pubDate>Fri, 23 Jan 2009 10:37:02 -0500</pubDate>
      <title>Re: Help using &quot;disp&quot;</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/242965#623408</link>
      <author>Daniel Eliasson</author>
      <description>&quot;P&quot; &amp;lt;pyjunk.nospam@shaw.ca&amp;gt; wrote in message &amp;lt;glc6b1$fr7$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hi again,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; fprintf is very powerful but it does sometime to get use to syntax.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; The magic format string '%3.1f' means 3 things&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; 1. 3 is Field Width, 'A digit string specifying the minimum number of digits to be printed'&lt;br&gt;
&amp;gt; 2. 1 is Precision, 'A digit string including a period (.) specifying the number of digits to be printed to the right of the decimal point'&lt;br&gt;
&amp;gt; 3. f implies fixed-point notation.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; So yes you need to change the 1 to get to the other decimal. The %x.y formatting allows you to line up strings very nicely.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; a=101&lt;br&gt;
&amp;gt; b=0.00001&lt;br&gt;
&amp;gt; fprintf('THIS IS %10.5f\n',a)&lt;br&gt;
&amp;gt; fprintf('THIS IS %10.5f\n',b)&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Thank you very much!</description>
    </item>
    <item>
      <pubDate>Fri, 23 Jan 2009 13:49:02 -0500</pubDate>
      <title>Re: Help using &quot;disp&quot;</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/242965#623440</link>
      <author>Thomas Clark</author>
      <description>fprintf is a pain. For generic formatting, use:&lt;br&gt;
&lt;br&gt;
disp(['The answer is: ' num2str(ans)])&lt;br&gt;
&lt;br&gt;
- Tom&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&quot;Daniel Eliasson&quot; &amp;lt;danielel@kth.se&amp;gt; wrote in message &amp;lt;glc6ke$4gn$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;P&quot; &amp;lt;pyjunk.nospam@shaw.ca&amp;gt; wrote in message &amp;lt;glc6b1$fr7$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; Hi again,&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; fprintf is very powerful but it does sometime to get use to syntax.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; The magic format string '%3.1f' means 3 things&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; 1. 3 is Field Width, 'A digit string specifying the minimum number of digits to be printed'&lt;br&gt;
&amp;gt; &amp;gt; 2. 1 is Precision, 'A digit string including a period (.) specifying the number of digits to be printed to the right of the decimal point'&lt;br&gt;
&amp;gt; &amp;gt; 3. f implies fixed-point notation.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; So yes you need to change the 1 to get to the other decimal. The %x.y formatting allows you to line up strings very nicely.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; a=101&lt;br&gt;
&amp;gt; &amp;gt; b=0.00001&lt;br&gt;
&amp;gt; &amp;gt; fprintf('THIS IS %10.5f\n',a)&lt;br&gt;
&amp;gt; &amp;gt; fprintf('THIS IS %10.5f\n',b)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thank you very much!&lt;br&gt;
&amp;gt; </description>
    </item>
    <item>
      <pubDate>Fri, 23 Jan 2009 14:04:50 -0500</pubDate>
      <title>Re: Help using &quot;disp&quot;</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/242965#623443</link>
      <author>Andrew</author>
      <description>On Jan 23, 6:49=A0am, &quot;Thomas Clark&quot; &amp;lt;t.cl...@remove.spamcantab.net&amp;gt;&lt;br&gt;
wrote:&lt;br&gt;
&amp;gt; fprintf is a pain. For generic formatting, use:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; disp(['The answer is: ' num2str(ans)])&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; - Tom&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &quot;Daniel Eliasson&quot; &amp;lt;danie...@kth.se&amp;gt; wrote in message &amp;lt;glc6ke$4g...@fred.m=&lt;br&gt;
athworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &quot;P&quot; &amp;lt;pyjunk.nos...@shaw.ca&amp;gt; wrote in message &amp;lt;glc6b1$fr...@fred.mathwor=&lt;br&gt;
ks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Hi again,&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; fprintf is very powerful but it does sometime to get use to syntax.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; The magic format string '%3.1f' means 3 things&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; 1. 3 is Field Width, 'A digit string specifying the minimum number of=&lt;br&gt;
&amp;nbsp;digits to be printed'&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; 2. 1 is Precision, 'A digit string including a period (.) specifying =&lt;br&gt;
the number of digits to be printed to the right of the decimal point'&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; 3. f implies fixed-point notation.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; So yes you need to change the 1 to get to the other decimal. The %x.y=&lt;br&gt;
&amp;nbsp;formatting allows you to line up strings very nicely.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; a=3D101&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; b=3D0.00001&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; fprintf('THIS IS %10.5f\n',a)&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; fprintf('THIS IS %10.5f\n',b)&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Thank you very much!&lt;br&gt;
&lt;br&gt;
How would you format -- disp(['The answer is: ' num2str(ans)])  -- to&lt;br&gt;
output a predetermined number of decimal places?  I think fprintf is&lt;br&gt;
great; but I also spend a lot of time in C.</description>
    </item>
    <item>
      <pubDate>Fri, 23 Jan 2009 14:09:10 -0500</pubDate>
      <title>Re: Help using &quot;disp&quot;</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/242965#623444</link>
      <author>Doug Schwarz</author>
      <description>In article &amp;lt;glc6ke$4gn$1@fred.mathworks.com&amp;gt;,&lt;br&gt;
&amp;nbsp;&quot;Daniel Eliasson&quot; &amp;lt;danielel@kth.se&amp;gt; wrote:&lt;br&gt;
&lt;br&gt;
&amp;gt; &quot;P&quot; &amp;lt;pyjunk.nospam@shaw.ca&amp;gt; wrote in message &lt;br&gt;
&amp;gt; &amp;lt;glc6b1$fr7$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; Hi again,&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; fprintf is very powerful but it does sometime to get use to syntax.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; The magic format string '%3.1f' means 3 things&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; 1. 3 is Field Width, 'A digit string specifying the minimum number of &lt;br&gt;
&amp;gt; &amp;gt; digits to be printed'&lt;br&gt;
&amp;gt; &amp;gt; 2. 1 is Precision, 'A digit string including a period (.) specifying the &lt;br&gt;
&amp;gt; &amp;gt; number of digits to be printed to the right of the decimal point'&lt;br&gt;
&amp;gt; &amp;gt; 3. f implies fixed-point notation.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; So yes you need to change the 1 to get to the other decimal. The %x.y &lt;br&gt;
&amp;gt; &amp;gt; formatting allows you to line up strings very nicely.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; a=101&lt;br&gt;
&amp;gt; &amp;gt; b=0.00001&lt;br&gt;
&amp;gt; &amp;gt; fprintf('THIS IS %10.5f\n',a)&lt;br&gt;
&amp;gt; &amp;gt; fprintf('THIS IS %10.5f\n',b)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thank you very much!&lt;br&gt;
&lt;br&gt;
You might be happier with %g:&lt;br&gt;
&lt;br&gt;
fprintf('The answer is %g.\n',x)&lt;br&gt;
&lt;br&gt;
-- &lt;br&gt;
Doug Schwarz&lt;br&gt;
dmschwarz&amp;ieee,org&lt;br&gt;
Make obvious changes to get real email address.</description>
    </item>
  </channel>
</rss>

