Umal-qura university


-------------------------TASK 04--------------------------



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

-------------------------TASK 04--------------------------


Plot the two curves y1 = 2x + 3 and y2 = 4x + 3 on the same graph using different plot styles.



        1. AXES COMMANDS (MANUAL ZOOMING)

MATLAB automatically adjusts the scale on a graph to accommodate the coordinates of the points being plotted. The axis scaling can be manually enforced by using the command axis([xmin xmax ymin ymax]). A signal can be zoomed out by specifying the axis coordinates by user himself.




Example:

x = -5*pi:.01:5*pi; y1=sin(x); plot(x,y1, 'r')


The plot is shown in the figure below.

In order to see only one cycle of this signal from 0 to 2π, the signal is zoomed using axis


command. Here we have specified xmin and xmax as 0 and 2π respectively.

x = -5*pi:0.01:5*pi; y1=sin(x); plot(x,y1, 'r')


axis([0 2*pi -1 1])
The magnified plot is shown in the figure below.

Similarly the y‐axis can be adjusted according to requirements.


x = -5*pi:0.01:5*pi; y1=sin(x); plot(x,y1, 'r')
axis([0 2*pi -2 2])



        1. LABELING A GRAPH

To add labels to your graph, the functions xlabel, ylabel, and title can be used as follows:


xlabel('x‐axis')
ylabel('y‐axis')
title('points in a plane')

        1. SUBPLOT

SUBPLOT Create axes in tiled positions.


MATLAB graphics windows will contain one plot by default. The command subplot can be used to partition the screen so that up to four plots can be viewed simultaneously. A single figure can be divided into a number of plotting areas where different graphs can be plotted. This can be accomplished by using the command subplot(m, n, p) where m, n specifies the total number of rows and columns respectively in the figure window and p specifies the specific cell to plot into.
x=0:1:10;
y=x.^2; z=10*x;

Now type the following code


figure
subplot (1,2,1) plot(x,y) subplot (1,2,2) plot(x,z)


In the above case subplot(m,n,p) command was used, in our case subplot (1,2,1) and subplot (1,2,2). Here m=1 means that divide the figure into 1 row, n=2 means to divide the figure into 2 columns. This gives us a total of 2 subplots in one figure. Where p=1 means the window on the left (starting from row 1 and counting p=1 subplots to the right) and p=2 means the subplot on the right (starting from row 1 and counting p=2 subplots to the right).





Yüklə 0,73 Mb.

Dostları ilə paylaş:
1   ...   12   13   14   15   16   17   18   19   ...   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ə