The basic calculation unit is a vector or a matrix in ScicosLab. What we get used to is a 1*1 matrix.
Define a Vector
Well, the result is stored in the variable
ans and the vector will be displayed hereafter. This vector is comprised of float numbers from 0 to 4π with a spacing of 0.1, they are 116 numbers, check this with the function
%pi is the Scicos way of pre-defining some constants. For the logarithmic natural base e, it uses
%e. To stop printing results after each command, one can end it with a semi-colon(;).
--> a = 0:0.1:4*%pi;
Variables are type-free when being declared, so the initialization will make the variable
a being a vector. Any assignment will change its content and type just like using a brand-new variable. The system preserved variable
ans will be updated in the same fashion after executing every command.
--> a = sin(a);
Plot a Sine Wave
This gives you a sine wave of 2 periods.
Perform Discret Fourier Transform
--> v = dft(a,-1); --> clf(); --> plot(v);
To check the usage of a function or related entries, use
--> apropos fourier --> help dft
To clear the graph/figure, use the function
clf(). We see in the new plotting
ScicosLab just drew the real part of frequency components, to compare with the imaginary parts, use
--> plot(imag(v), 'red');
The figure gets re-shaped and we see two spikes again. As a matter of fact, the Fourier transform of sine wave is two dirac functions.
--> browsevar --> clear
The former gives a window of currently being-used variables, and the latter command just destroys them.