home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / softsys / matlab / 144 < prev    next >
Encoding:
Internet Message Format  |  1993-01-25  |  1.8 KB

  1. Path: sparky!uunet!cs.utexas.edu!geraldo.cc.utexas.edu!slcs.slb.com!leo.asc.slb.com!leo.asc.slb.com!gray
  2. From: gray@snow.scr.slb.com (Douglas Gray Stephens)
  3. Newsgroups: comp.soft-sys.matlab
  4. Subject: Re: DISP1:  disp1.m - display text and numbers
  5. Date: 25 Jan 93 09:37:51
  6. Organization: Schlumberger Cambridge Research
  7. Lines: 31
  8. Message-ID: <GRAY.93Jan25093751@snow.scr.slb.com>
  9. References: <1993Jan23.152729.26892@news.columbia.edu>
  10.     <1993Jan23.233224.11781@netnews.whoi.edu>
  11. NNTP-Posting-Host: snow.scr.slb.com
  12. In-reply-to: rich@boreas.whoi.edu's message of Sat, 23 Jan 93 23:32:24 GMT
  13.  
  14. In article <1993Jan23.233224.11781@netnews.whoi.edu> rich@boreas.whoi.edu writes:
  15.  
  16.    >Trying to continue the trend, here is an m-file for display
  17.    >text and numbers to the screen on a single line.  I had m-files
  18.    >filled with statements like
  19.    >   disp('x measures blah blah, its value is');  disp(x);
  20.    >which (a) uses 2 display statements and (b) does not appear
  21.    >on a single line on the screen.  The m-file disp1.m allows the
  22.    >statement
  23.    >   disp1('x measures blah blah, its value is ', x);
  24.    >
  25.    > [script deleted]
  26.  
  27.    You don't need an m-file for that - just use:
  28.  
  29.    disp(['x measures blah blah, its value is ' num2str(x)]);
  30.  
  31. If you want more control over the format of the numbers, you should
  32. use the fprintf command, e.g.
  33.  
  34.   fprintf('x measures blah blah, its value is %.4g\n',x)
  35.  
  36. (you also have more explicit control over the line breaks).
  37.  
  38.  
  39. --
  40. ----------------------------------------------------------------------------
  41. Dr. Douglas GRAY STEPHENS                e-mail : gray@scr.slb.com   
  42. Schlumberger Cambridge Research          Tel/fax: 0223-325303 / 0223-311830
  43. P.O.Box 153, Cambridge CB3 0HG, England  (International prefix for UK: 44)
  44. ============================================================================
  45.