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

9.7.8 STFA sample

../png/stfa

C++ code

mglData a(2000), b(2000);
a.Fill("cos(50*pi*x)*(x<-.5)+cos(100*pi*x)*(x<0)*(x>-.5)+ \
        cos(200*pi*x)*(x<.5)*(x>0)+cos(400*pi*x)*(x>.5)", 
        gr->Min, gr->Max);
gr->SubPlot(1, 2, 0);
gr->Plot(a);
gr->Axis();
gr->Label('x', "\\i t");
gr->SubPlot(1, 2, 1);
gr->STFA(a, b, 64);
gr->Axis();
gr->Label('x', "\\i t");
gr->Label('y', "\\omega", 0);

MGL code

new a 2000
new b 2000
fill a 'cos(50*pi*x)*(x<-.5)+cos(100*pi*x)*(x<0)*(x>-.5)+
        cos(200*pi*x)*(x<.5)*(x>0)+cos(400*pi*x)*(x>.5)'
subplot 1 2 0
plot a
axis
xlabel '\i t'
subplot 1 2 1
stfa a b 64 ''
axis
ylabel '\omega' 0
xlabel '\i t'

Pure C code

HMDT a = mgl_create_data_size(2000,1,1);
HMDT b = mgl_create_data_size(2000,1,1);
mgl_data_fill_eq(gr, a, "cos(50*pi*x)*(x<-.5)+cos(100*pi*x)*(x<0)*(x>-.5)+ \
        cos(200*pi*x)*(x<.5)*(x>0)+cos(400*pi*x)*(x>.5)",0,0);
mgl_subplot(gr,1,2,0);
mgl_plot(gr,a,"");
mgl_axis(gr,"xy");
mgl_label(gr,'x', "\\i t");
mgl_subplot(gr,1,2,1);
mgl_stfa(gr,a,b,64,"",0.);
mgl_axis(gr,"xy");
mgl_label(gr,'x', "\\i t");
mgl_label(gr,'y', "\\omega");

Fortran code

integer a,b, mgl_create_data_size
a = mgl_create_data_size(2000,1,1)
b = mgl_create_data_size(2000,1,1)
call mgl_data_fill_eq(gr, a, 'cos(50*pi*x)*(x<-.5)+cos(100*pi*x)*(x<0)*(x>-.5)+ &
        cos(200*pi*x)*(x<.5)*(x>0)+cos(400*pi*x)*(x>.5)',0,0)
call mgl_subplot(gr,1,2,0)
call mgl_plot(gr,a,'')
call mgl_axis(gr,'xy')
call mgl_label(gr,'x', '\i t')
call mgl_subplot(gr,1,2,1)
call mgl_stfa(gr,a,b,64,'',0.)
call mgl_axis(gr,'xy')
call mgl_label(gr,'x', '\i t')
call mgl_label(gr,'y', '\omega')

Python

a, b = mglData(2000), mglData(2000);
gr.Fill(a,"cos(50*pi*x)*(x<-.5)+cos(100*pi*x)*(x<0)*(x>-.5)+ \
        cos(200*pi*x)*(x<.5)*(x>0)+cos(400*pi*x)*(x>.5)");
gr.SubPlot(1, 2, 0);
gr.Plot(a);
gr.Axis();
gr.Label('x', "\\i t");
gr.SubPlot(1, 2, 1);
gr.STFA(a, b, 64);
gr.Axis();
gr.Label('x', "\\i t");
gr.Label('y', "\\omega", 0);

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