Professional Documents
Culture Documents
Faisal ur Rehman
y=exp(-1.2*x).*sin(10*x+5);
subplot(1,2,1)
plot(x,y),xlabel('x');ylabel('y')
axis([0 5 -1 1])
subplot(1,2,2)
z=abs(x.^3-100);
plot(x,z)
%to bring new figure for plot
figure
plot(x,y)
%to close current figure
close figure 2
%to close all figure
close all
%Log Graphs
loglog(x,z)
grid on
semilogx(x,z)
grid on
semilogy(x,z)
grid on
%bar charts
x=[1 2 3 4];y=[2 3 4 5];
bar(x,y)
clc
% use of ginput
x=[0:.01:5];
y=2*sqrt(x);
z=4*sin(3*x);
plot(x,y,x,z)
title('Plot of Sine and Sqrt line')
[xi yi]=ginput(5)
%to find intersection points of 2 lines
[xi yi]=polyxpoly(x,y,x,z)
clc
%set limits of axis
axis([0 5 -5 5])
close all
clc
Engineering Programs -enggprog.com Engr. Faisal ur Rehman
set(gca,'XTicklabel',{'-pi','-pi/2','0','pi/2','pi'})
clc
%Aspect Ratio
t=[0:pi/20:20*pi];
plot(sin(t),2*cos(t));
t=[0:pi/20:2*pi];
plot(sin(t),2*cos(t));
grid on
axis square
axis normal
axis equal tight
axis equal
clc
close all
clc
hl2=line(x2,y2,'color','k','Parent',ax2);