Professional Documents
Culture Documents
Chap4 - Plotting in MATLAB
Chap4 - Plotting in MATLAB
>> x1 = linspace(0,6*pi);
>> x2 = linspace(0,6*pi,15);
>> plot(x1,sin(x1),x2,sin(x2));
plot
>>
>>
>>
>>
>>
>>
>>
>>
x = -2:0.01:10; clf;
y = sin(x);
plot(x,y,'r'); hold on;
y = sin(2*y);
plot(x,y,'m');
y = sin(2*sin(2*y));
plot(x,y,'b'); hold off;
axis([-2 10 -1.5 1.5]);
help plot
plot
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
P = linspace(10,1000);
T = 1730.63./(8.07131-log10(P))-233.426;
subplot(2,2,1);
plot(P,T); title('Linear Axes'); grid on;
subplot(2,2,2);
semilogx(P,T); title('SemilogX'); grid on;
subplot(2,2,3);
semilogy(P,T); title('SemilogY'); grid on;
subplot(2,2,4);
loglog(P,T); title('Log-log Plot'); grid on;
semilogx, semilogy
loglog
>> t = 0:0.02:6*pi;
>> r = 2*cos(4*t/3);
>> polar(t,r,'>k');
>>
>>
>>
>>
t = 0:0.01:100;
x = cos(3*t);y = sin(2*t); z = t.^2;
plot3(x,y,z);
xlabel('x'); ylabel('y'); zlabel('z');
surf(peaks);
axis equal;
axis off;
axis on;
axis auto;
plot
subplot
plot
plotyy
semilogx, semilogy, loglog
plot3
plot(x1,y1,LineSpec1,x2,y2,LineSpec2)
x1
x2
x1
y1
plot
LineSpec
y1
x2
y2
y2
>> x = 0:0.2:5;
>> y = (2.^x) (x.^2) 2;
>> plot(x,y,--r);
--r
r--
clf
>> y2 = log(x^.3);
>> plot(x,y,--ro,x,y2,-.bd);
plot
plot(x,y,LineSpec, PropertyName, PropertyValue)
5
PropertyName
PropertyValue
LineWidth
MarkerSize
MarkerEdgeColor
MarkerFaceColor
help plot
plot
help plot
plot
axis
grid
legend
text
xlabel
ylabel
title
xlabel(TIME (s))
plot
subplot
subplot
subplot(nrows,ncolumns,plotnumber); plot(x,y);
subplot
subplot
plot
plot
subplot
subplot(2,2,2)
subplot
subplot(2,3,5)
>>
>>
>>
>>
7
>>
>>
>>
>>
>>
>>
subplot(2,2,2);
plot(x,y2,'-.bd'); grid on
subplot(2,2,3);
plot(x,y2,'--rd'); grid on
subplot(2,2,4);
plot(x,y,'-.bo'); grid on
plotyy
plotyy(x1,y1,x2,y2)
x1
>>
>>
>>
>>
>>
y1
x = -5:0.1:5;
clf;
y1 = ceil(x.^2);
y2 = abs(x)+2;
plotyy(x,y1,x,y2);
x2
y2
plotyy
a = plotyy(x1,y1,x2,y2);
ylabel(a(1), label1);
ylabel(a(2), label2);
a(1)
>>
>>
>>
>>
>>
>>
>>
>>
a(2)
x = -5:0.1:5;
clf;
y1 = ceil(x.^2);
y2 = abs(x)+2;
a = plotyy(x,y1,x,y2);
xlabel('x');
ylabel(a(1), 'y1');
ylabel(a(2), 'y2');
loglog
plot
semilogx
semilogy
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
P = linspace(10,1000);
T = 1730.63./(8.07131-log10(P))-233.426;
subplot(2,2,1);
plot(P,T); title('Linear Axes'); grid on;
subplot(2,2,2);
semilogx(P,T); title('SemilogX'); grid on;
subplot(2,2,3);
semilogy(P,T); title('SemilogY'); grid on;
subplot(2,2,4);
loglog(P,T); title('Log-log Plot'); grid on;
plot3
plot3
plot3(x1,y1,z1,x2,y2,z2)
t = 0:0.01:100;
x = cos(3*t);
y = sin(2*t);
z = t.^2;
plot3(x,y,z);
xlabel('x');
ylabel('y');
zlabel('z');
plot