Umal-qura university



Yüklə 0,73 Mb.
səhifə15/30
tarix23.12.2023
ölçüsü0,73 Mb.
#156716
1   ...   11   12   13   14   15   16   17   18   ...   30
Signal and Systems Manual - v2full

Two-dimensional plots

The plot command creates linear x‐y plots; if x and y are vectors of the same length, the command plot(x,y) opens a graphics window and draws an x‐y plot of the elements of x versus the elements of y.




Example: Let's draw the graph of the sine function over the interval ‐4 to 4 with the following
commands:
>> x = ‐4:.01:4; y = sin(x); plot(x,y)
>> grid
>> xlabel('x')
>> ylabel('sin(x)')
The vector x is a partition of the domain with meshsize 0.01 while y is a vector giving the values of sine at the nodes of this partition (recall that sin operates entrywise). Following figure shows the result.


        1. MULTIPLE PLOTS ON SAME FIGURE WINDOW

Two ways to make multiple plots on a single graph are:



          1. Single plot command x = 0:.01:2*pi; y1=sin(x);

y2=sin(2*x);
y3 = sin(4*x); plot(x,y1,x,y2,x,y3)

          1. Multiple plot commands

Another way is with hold. The command hold freezes the current graphics screen so that subsequent plots are superimposed on it. Entering hold again releases the ``hold.''

x = 0:.01:2*pi;


y1=sin(x); y2=sin(2*x); y3 = sin(4*x); plot(x,y1); hold on; plot(x, y2);


plot(x,y3);



        1. OVERRIDING THE DEFAULT PLOT SETTINGS

One can override the default linetypes and pointtypes. For example, the command sequence


x = 0:.01:2*pi; y1=sin(x); y2=sin(2*x); y3=sin(4*x);
plot(x,y1,'--',x,y2,':',x,y3,'+') grid
title ('Dashed line and dotted line graph')

The line‐type and mark‐type are


=============================================================
Linetypes : solid (-), dashed (-). dotted (:), dashdot (-.)
Marktypes : point (.), plus (+), star (*, circle (o), x-mark (x)
=============================================================



Yüklə 0,73 Mb.

Dostları ilə paylaş:
1   ...   11   12   13   14   15   16   17   18   ...   30




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©genderi.org 2024
rəhbərliyinə müraciət

    Ana səhifə