Article View: comp.soft-sys.matlab
Article #44Re: DISP1: disp1.m - display text and numbers
From: Douglas Gray Stephens
Date: Mon, 25 Jan 1993 09:37
Date: Mon, 25 Jan 1993 09:37
31 lines
1877 bytes
1877 bytes
In article <1993Jan23.233224.11781@netnews.whoi.edu> rich@boreas.whoi.edu writes:
>Trying to continue the trend, here is an m-file for display
>text and numbers to the screen on a single line. I had m-files
>filled with statements like
> disp('x measures blah blah, its value is'); disp(x);
>which (a) uses 2 display statements and (b) does not appear
>on a single line on the screen. The m-file disp1.m allows the
>statement
> disp1('x measures blah blah, its value is ', x);
>
> [script deleted]
You don't need an m-file for that - just use:
disp(['x measures blah blah, its value is ' num2str(x)]);
If you want more control over the format of the numbers, you should
use the fprintf command, e.g.
fprintf('x measures blah blah, its value is %.4g\n',x)
(you also have more explicit control over the line breaks).
--
----------------------------------------------------------------------------
Dr. Douglas GRAY STEPHENS e-mail : gray@scr.slb.com
Schlumberger Cambridge Research Tel/fax: 0223-325303 / 0223-311830
P.O.Box 153, Cambridge CB3 0HG, England (International prefix for UK: 44)
============================================================================
Technical Details
Message-ID:
<GRAY.93Jan25093751@snow.scr.slb.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!geraldo.cc.utexas.edu!slcs.slb.com!leo.asc.slb.com!leo.asc.slb.com!grayReferences:
<1993Jan23.152729.26892@news.columbia.edu> <1993Jan23.233224.11781@netnews.whoi.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!geraldo.cc.utexas.edu!slcs.slb.com!leo.asc.slb.com!leo.asc.slb.com!gray From: gray@snow.scr.slb.com (Douglas Gray Stephens) Newsgroups: comp.soft-sys.matlab Subject: Re: DISP1: disp1.m - display text and numbers Date: 25 Jan 93 09:37:51 Organization: Schlumberger Cambridge Research Lines: 31 Message-ID: <GRAY.93Jan25093751@snow.scr.slb.com> References: <1993Jan23.152729.26892@news.columbia.edu> <1993Jan23.233224.11781@netnews.whoi.edu> NNTP-Posting-Host: snow.scr.slb.com In-reply-to: rich@boreas.whoi.edu's message of Sat, 23 Jan 93 23:32:24 GMT