Documente Academic
Documente Profesional
Documente Cultură
This week you will see how to plot a function in Scilab. However there are some pitfalls to avoid. The
command plot is easy, the hard bit is to get the range of the variables right.
After each question, make rough sketches of the plots you see in the graphics window, and write down
the corresponding mathematical functions.
You meet the Scilab commands
plot linspace xgrid title figure clf() clear
Q 11.1 A simple plot.
Start Scilab.
x = -3:5
y = 2*x + 3
plot(x,y)
y Why?
Note: When the figure window is open you can select Edit, Axes Properties to edit options like
axis labels, titles.
Q 11.8 Argand diagram.
Complex numbers are plotted in the Argand diagram. First set up the axes, add a grid and hold
the diagram.
clf()
mtlb_axis([-5,5,-5,5]),
xgrid(1)
Then define the points and vectors to draw.
z = -1+1.5*%i
plot(real(z),imag(z),x), // plots real and imaginary parts of z
nought = 0+0*%i
plot([real(nought);real(z)],[imag(nought);imag(z)])
z2=z^2
plot([real(nought);real(z2)],[imag(nought);imag(z2)])
Identify the points and lines.
Q 11.9 Polar coordinates.
A plot in polar coordinates:
clf()
theta = %pi/4
// radians
theta*360/(2*%pi)
// degrees
z = 3+4*%i
theta = atan( real(z)/imag(z) ) // radians
r = abs(z)
r*( sin(theta) + %i*cos(theta) ) // z !!!
// now to plot
theta = linspace(0,2*%pi) ; // 100 points
r = 1+cos( 2*(theta-%pi/6) ) ;
polarplot(theta,r)
You may need to resize your window to see the entire plot.
Add a title to your plot using Edit, Axes Properties (remember to click out of the box for the title
to appear).
Why are the two eggs orientated at 30degrees? What are the effects on this curve of doubling
(i) the period shift at 2*
3
[Rho, Theta]=polar(z)
Theta =
0.9272952 - 8.327D-17i
Rho =
5.
Q 11.10 Solving equations.
Using a suitable interval for x plot
y = 2 (x 3)2
and
y = x/2 + 1
Do the two graphs intersect?