kill(all)$

Maxima : plot  data ( = discrete) from a Matrix
peter.vlasschaert@gmail.com, 17/01/2019

How to convert  : Matrix to List.  (reason : plot data)
===========================================

1e) given  : Matrix  ?   ( Data : from spreadsheet : 'import from LibreOffice(calc)')
------------------------------------------------------------------------------------------------------------------------
first       column : x
second column :y1
third      column :y2
fourth   column : y3

p1:zeromatrix(5,5);

insert element matrix

p2: p1[1,1] : 1;

p1a:p1;

?  build matrix  ' representation for data '
================================================
Menu : Algebra : Enter Matrix          , " ' 5 by 4 ', Name : qq"
Rows : 5
Column : 4
Type : general
Name : qq
================================================

qq: matrix(
 [1,1,1,2], 
 [3,2,3,5], 
 [5,3,5,16], 
 [11,4,7,13], 
 [14,5,9,18]
);

q:transpose(qq);

2e)   matrix  to list.  ' command :args '
--------------------------------------------------------

p2:args(q);

length list : 'p2'
=========

p2a:length(q) ;

part of big list: 'p2'
============

p3:   p2[1];          /* x  data*/
p3a: p2[2];       /*y1   data*/
p3b: p2[3];       /*y2   data*/
p4b: p2[4];      /*y3    data*/

3e) combination (x,y1),(x,y2),(x,y3)
--------------------------------------------------------

===============================
number : points 5   =>  (x,yi)    , i=1,2,3
===============================

a)  number of points.
=================

nu:length(p2[1]);

b) points , coordinates  ( example : 'x,y1')
==================================

p4:[];

for i:1 thru nu  do(
p4:endcons([p3[i],p3a[i]],p4)    
);

we need list to plot the discrete data  ' (x,y) pair '
========================================

p4;

help maxima :  'plot'
=================

(%i1) xy: [[10, .6], [20, .9], [30, 1.1], [40, 1.3], [50, 1.4]]$
(%i2) plot2d([[discrete, xy], 2*%pi*sqrt(l/980)], [l,0,50],
        [style, points, lines], [color, red, blue],
        [point_type, asterisk],
        [legend, "experiment", "theory"],
        [xlabel, "pendulum's length (cm)"],
        [ylabel, "period (s)"])$

plot discrete data  (from the experiment) {x,y1}
=======================================

        wxplot2d([ [discrete,p4],[discrete,p4]], [x,0,15], [y,0,6],
        [style, points, lines], [color, red, blue],
        [point_type, asterisk],
        [legend, "data x versus y1"],
        [xlabel, "x"],
        [ylabel, "y1"],grid2d)$

rem :(x,y1) : p4

 function :  [[,],[,],.........]
===================

discr_xy(k1,k2) := block([l1:[]],
nu:length(k1),
for i:1 thru nu 
do(l1:endcons([k1[i],k2[i]],l1)),
 l1
                                     )$    

plot :two different data sets  {(x,y1),(x,y2)}
====================================

p5:discr_xy(p3,p3a);

rem :(x, y1):p5

p6:discr_xy(p3,p3b);

rem :(x, y2):p6

  wxplot2d([ [discrete,p5],[discrete,p6]], [x,0,15], [y,0,15],
        [style, points, points], [color, red, blue],
        [point_type, asterisk],
        [legend, "data x versus y1","data x versus y2"],
        [xlabel, "x"],
        [ylabel, "y1,y2"],grid2d)$

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------