home *** CD-ROM | disk | FTP | other *** search
- # library modelplo
- # modelplo(model,x, [x1,x2,...],[y1,y2,...])
- # fits and plots data ([x1,x2,...], [y1,y2,...] ) into a model
- # e.g. fitplot(x^2,x, [1,2,3,4], [1,4,9,16])
-
- modelplo(model_,x_,xdata_, ydata_) := block(numeric:=on,
- graph,
- xmax:=max(xdata)*1.05,
- xmin:=min(xdata)*0.9,
- ymax:=max(ydata)*1.05,
- ymin:=min(ydata)*0.9,
- dx:=(xmax-xmin)/getmaxx,
- dy:=(ymax-ymin)/getmaxy,
- length:=length(ydata),
- axis(xmin,xmax,ymin,ymax),
- do( circle((member(xdata,j)-xmin)/dx,getmaxy-(member(ydata,j)-ymin)/dy,2),
- j,1,length,1),
- xstep:=dx*10,
- setcolor(colorno(yellow)),
- moveto(0,getmaxy-(subs(model,x=xmin)-ymin)/dy),
- do( lineto((x-xmin)/dx,getmaxy-(model-ymin)/dy),
- x,xmin,xmax,xstep),
- numeric:=off,
- readchar,
- text,
- local(dx,dy,length,xstep))