Saving and Plotting Arrays



--- Lorenzo Isella  wrote:

> Say that I saved some data in a Nx2 array like:
>       
>       y       x
> 
>      0.05   0.0039
>      0.10   0.0014
>      0.15   0.0033
>      0.20   0.0066
> 
> I would like to plot them (1st column: dependent
> variable, 2nd independent variable).
> I can create two lists correponding to the 2 colmns of
> the matrix e.g.:
> 
> L_y:makelist(Matrix[i,1],i,1,N);

OK, let's be careful about terminology here -- an array
is not the same thing as a matrix in Maxima. I'll assume
you want to work with matrices.

Let M be a matrix, obtained via read_matrix for example.
A matrix is stored as a list of rows with the operator "matrix".
So args(M) is the list of rows. args(transpose(M)) is the
list of columns. In your example, you can have

  L: args(transpose(M));
  L_x: second(L);
  L_y: first(L);

> , but on the Maxima manual, it seems that the element
> of the lists in open_plot have to entered as 
> [[x1, y1, x2, y2, ...] or [[[x1, y1], [x2, y2], ...],
> ...] , which is not what I have in mind.
> Since the 2 columns can be very long, I cannot simply
> type in the list of values.

Good news, bad news wrt plotting. Bad news: openplot_curves
may well be broken. Good news: support for plotting discrete
points was recently added to plot2d. Bad news: discrete
point support isn't in 5.9.1 and it doesn't appear to be
possible to simply load("plot.lisp") to get the new version
(due to other changes in plot.lisp). Neutral news: it is
possible to plot discrete points in 5.9.1 plot2d by a
crufty hack; see "How do I plot a list of points?" at
http://maxima.sf.net/wiki/index.php/Maxima%20helpful%20hints

The documentation for plot2d was updated recently. 
See "Definitions for Plotting" at
http://maxima.sourceforge.net/docs/original/maxima_toc.html

> Furthermore, can Maxima save the 2 columns both
> separately and together in order to be read as a
> matrix by another plotting tool?

You can use write_data(mymatrix, "foo.out") (in numericalio)
to write a file which can be read by other programs.
Maybe I don't understand what you want here.

Sorry that I don't have any simple answer to the plotting problem.
Hope this helps & all the best,

Robert Dodier


		
__________________________________ 
Discover Yahoo! 
Find restaurants, movies, travel and more fun for the weekend. Check it out! 
http://discover.yahoo.com/weekend.html