Professional Documents
Culture Documents
5:
x=2*pi:pi/10:2*pi;
y=sin(x);
h=plot(x,y);
xlabel('x');
ylabel('y');
Output:
a) Code:
x=-2*pi:pi/10:2*pi;
y=sin(x);
h=plot(x,y);
get(h)
set(h,'color',[0,1,0]);
xlabel('x');
ylabel('y');
Output:
b) Code:
x=-2*pi:pi/10:2*pi;
y=sin(x);
h=plot(x,y);
get(h);
set(h,'LineStyle','--');
xlabel('x');
ylabel('y');
Output:
c) Code:
x=-2*pi:pi/10:2*pi;
y=sin(x);
h=plot(x,y);
get(h);
set(h,'linewidth',2);
xlabel('x');
ylabel('y');
Output:
Matlab Problem 14.7:
a) Code:
x=-2*pi:pi/10:2*pi;
y=sin(x);
plot(x,y,'r');
xlabel('x');
ylabel('y');
h=gca;
get(gcf);
set(h,'color',[0 0 1]);
Output:
b) Code:
x=-2*pi:pi/10:2*pi;
y=sin(x);
plot(x,y,'r');
xlabel('x');
ylabel('y');
h=gca;
get(gcf);
set(h,'xscale','log');
Output:
Matlab Problem 14.9:
Code:
y1=[2345,4363,3212,4565,8776,7679,6532,2376,2238,4509,5643,1137];
y2=[2343,5766,4534,4719,3422,2200,3454,7865,6543,4508,2312,4566];
plot(y1);
hold on
plot(y2);
months={'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','No
v','Dec'};
set(gca,'xtick',1:12,'xticklabel',months);
legend('2015','2016')
title('Comparison of Production')
Output:
Output:
Zoom in now
Move and point the cursor where you want to zoom
Region Selection
Zoomed Region