home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.soft-sys.matlab
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!howland.reston.ans.net!sol.ctr.columbia.edu!news.columbia.edu!cunixf.cc.columbia.edu!mnb2
- From: mnb2@cunixf.cc.columbia.edu (Mark Nathan Broadie)
- Subject: DISP1: disp1.m - display text and numbers
- Message-ID: <1993Jan23.152729.26892@news.columbia.edu>
- Sender: usenet@news.columbia.edu (The Network News)
- Nntp-Posting-Host: cunixf.cc.columbia.edu
- Reply-To: mnb2@cunixf.cc.columbia.edu (Mark Broadie)
- Organization: Columbia University
- Date: Sat, 23 Jan 1993 15:27:29 GMT
- Lines: 43
-
- 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);
-
- Keep these submissions coming!
-
- -mark broadie
-
-
- ------ cut here -------
-
- function disp1(s1, s2, s3, s4, s5, s6, s7, s8, s9, s10);
- % DISP1
- % displays up to ten arguments on the screen
- % e.g., x = 2.3;
- % disp1('x = ', x, ', 2*x = ', 2*x);
- % will print 'x = 2.3, 2*x = 4.6' on the screen
-
- % Mark Broadie 1-20-93
- % Copyright (c) 1993.
-
- s = [];
- for i = 1 : nargin;
- x = eval(['s',int2str(i)]);
-
- % num2str.m code follows with '%.6g' replacing '%.4g'
- if isstr(x)
- t = x;
- else
- t = sprintf('%.6g',x);
- end
-
- s = [s t];
- end;
-
- disp(s);
-
- % end of disp1.m
-