🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.soft-sys.matlab
Article #18

SOURCE: mat2str.m - convert matrix to string format

#18
From: Michael Maurer
Date: Sat, 23 Jan 1993 01:04
52 lines
1974 bytes
Hoping to start a trend, here is an unsolicited matlab m-file.
MAT2STR is like NUM2STR, but operates on matrix input.
Suggested improvements are welcome.

#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
#	mat2str.m
# This archive created: Fri Jan 22 16:55:43 1993
export PATH; PATH=/bin:$PATH
echo shar: extracting "'mat2str.m'" '(468 characters)'
if test -f 'mat2str.m'
then
	echo shar: will not over-write existing file "'mat2str.m'"
else
sed 's/^XX//' << \SHAR_EOF > 'mat2str.m'
XXfunction T=mat2str(X,nc,nd)
XX
XX%MAT2STR
XX%	T=mat2str(X) converts matrix X into string format T, using sprintf
XX%	to convert each element of X.
XX%	T=mat2str(X,nc) uses nc characters for each column, instead of
XX%	default 12.
XX
XX%	Michael Maurer, 10 Jan 1992
XX%	Copyright (c) 1993 by Michael Maurer
XX
XXif nargin<2,
XX   nc=12;
XXend
XX
XX[mx,nx]=size(X);
XXT=ones(mx,nc*nx)*abs(' ');
XXfor i=1:mx,
XX   for j=1:nx,
XX      t=sprintf('%.4g',X(i,j));
XX      T(i,nc*(j-1)+(1:length(t)))=t;
XX   end
XXend
SHAR_EOF
if test 468 -ne "`wc -c < 'mat2str.m'`"
then
	echo shar: error transmitting "'mat2str.m'" '(should have been 468 characters)'
fi
fi # end of overwriting check
#	End of shell archive
exit 0
--
______________________________________________________________________
Michael Maurer          maurer@nova.stanford.edu        (415) 723-1024
Technical Details
Message-ID: <maurer.727751047@nova.Stanford.EDU>
Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!nntp.Stanford.EDU!forsythe.stanford.edu!nova!maurer

Show Full Headers
Complete Article Headers
Newsgroups: comp.soft-sys.matlab
Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!nntp.Stanford.EDU!forsythe.stanford.edu!nova!maurer
From: Michael Maurer <maurer@nova.stanford.edu>
Subject: SOURCE: mat2str.m - convert matrix to string format
Message-ID: <maurer.727751047@nova.Stanford.EDU>
Sender: news@leland.Stanford.EDU (Mr News)
Organization: STAR Lab, Stanford University, California USA
Date: 23 Jan 93 01:04:07 GMT
Lines: 52