manpagez: man pages & more
info mathgl
Home | html | info | man
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.1.1 Plot sample

../png/plot

C++ code

mglData y(50,3);
y.Modify("0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)",0);
y.Modify("sin(2*pi*x)",1);
y.Modify("cos(2*pi*x)",2);
gr->Box();
gr->Plot(y);

MGL code

new y 50 3
modify y '0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)'
modify y 'sin(2*pi*x)' 1
modify y 'cos(2*pi*x)' 2
box
plot y

Pure C code

HMDT y = mgl_create_data_size(50,3,1);
mgl_data_modify(y,"0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)",0);
mgl_data_modify(y,"sin(2*pi*x)",1);
mgl_data_modify(y,"cos(2*pi*x)",2);
mgl_box(gr,1);
mgl_plot(gr,y,NULL);
mgl_delete_data(y);

Fortran code

integer y, mgl_create_data_size
y = mgl_create_data_size(50,3,1)
call mgl_data_modify(y,'0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)',0)
call mgl_data_modify(y,'sin(2*pi*x)',1)
call mgl_data_modify(y,'cos(2*pi*x)',2)
call mgl_box(gr,1)
call mgl_plot(gr,y,'')
call mgl_delete_data(y)

Python

y = mglData(50,3);
y.Modify("0.7*sin(2*pi*x)+0.5*cos(3*pi*x)+0.2*sin(pi*x)",0);
y.Modify("sin(2*pi*x)",1);
y.Modify("cos(2*pi*x)",2);
gr.Box();
gr.Plot(y);

© manpagez.com 2000-2024
Individual documents may contain additional copyright information.