From help-octave-request at che dot utexas dot edu Sat Apr 15 23:49:19 1995 Subject: Octave mesh plots using Plotmtv - again! From: Ted dot Harding at nessie dot mcc dot ac dot uk (Ted Harding) To: help-octave at che dot utexas dot edu Date: Sun, 16 Apr 1995 00:47:49 +0200 (BST) Hi All ... If you took an interest in the earlier posts about using Plotmtv, you may have wondered what the command "write" was doing. Its m-file is appended (it goes back to a long time before variable- length argument lists were implemented ... a utility written for MatLab vintage 1988, to be precise!) Apologies again - time I spent a day taking the dogs for a long walk, maybe. Ted. (Ted dot Harding at nessie dot mcc dot ac dot uk) ------------------------------ write.m ------------------------------------- function write(file,fmt,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10) # # write('filename','format',x1,x2,x3,x4,x5,x6,x7,x8,x9,x10) # # writes the data in the rows of matrices x1,x2,... # side-by-side into the rows of (APPEND mode). # # 'format' is a C f,e or g format (e.g.'%7.4f') for a single number. # 'format' is mandatory, 'filename' is optional and, if omitted, # output is to the screen. If 'filename' exists the output is appended. # # There must be at least one matrix argument x1, and at most 10. # The matrices x1, x2, ... are output side by side; all must have the # same number of rows. # s_temp = empty_list_elements_ok; empty_list_elements_ok = "true"; strargs=1; if isstr(fmt), strargs=2; end if strargs==1, FIL="stdout"; X=fmt; FMT=file; P=1; else X=[]; FMT=fmt; FIL=file; P=0; end if (nargin-strargs)>P+0, X=[X x1]; end if (nargin-strargs)>P+1, X=[X x2]; end if (nargin-strargs)>P+2, X=[X x3]; end if (nargin-strargs)>P+3, X=[X x4]; end if (nargin-strargs)>P+4, X=[X x5]; end if (nargin-strargs)>P+5, X=[X x6]; end if (nargin-strargs)>P+6, X=[X x7]; end if (nargin-strargs)>P+7, X=[X x8]; end if (nargin-strargs)>P+8, X=[X x9]; end if (nargin-strargs)>P+9, X=[X x10]; end S=size(X); R=S(1); C=S(2); fopen(FIL,"a"); for i=1:R for j=1:C fprintf(FIL,FMT,X(i,j)), fprintf(FIL,' '), end, fprintf(FIL,'\n') end fflush(FIL); if (strargs==2) fclose(FIL); end empty_list_elements_ok = s_temp; endfunction ============================================================================