File: depart\134math\134maple\134misc\134dataio.mws Date: 12-jan-1998 By: bob jantzen Data I/O in MAPLE (readdata, writedata) Maple can read in from or write to a file columns of numbers with the readdata and writedata commands explained in their help pages. A single column is read in as a list, while multiple columns are read in as an array. The columns of data written out are separated by tabs. We make some data and write it out and read it back in as an example: f:=x->x^2; Data:=[seq([i,f(i)],i=1..10)]; You have to edit the file address to a diskette or directory where you have write privileges to execute this yourself: writedata(`c:\134\134local\134\134mpltest.dat`,Data); To see the output, you can write it to your screen: writedata(terminal,Data); Now we read it back in: Data:=readdata(`c:\134\134local\134\134mpltest.dat`,integer,2); or just the first column as a list: readdata(`c:\134\134local\134\134mpltest.dat`,integer);
<Text-field style="Heading 1" layout="Heading 1">Analyzing the data (least squares fit)</Text-field> Now to look at the data: with(stats); with(statplots); with(plots): Data; nops(Data); Data[10,2]; We extract the columns of data: X:=[seq(Data[i,1],i=1..nops(Data))]; Y:=[seq(Data[i,2],i=1..nops(Data))]; scatterplot(X,Y); ptplt:=%: fitfunc:=fit[leastsquare[[x,y],y=a*x^2+b*x+c]]([X,Y]); plot(rhs(fitfunc),x=0..10); crvplt:=%: with(plots): display({crvplt,ptplt});