1. Drawing two-dimensional graphics
Example 1 First draw a simple two-dimensional graphics
multiple curves
t=(0:pi/50:2*pi)';k=0.4:0.1:1;Y=cos(t)*k;plot(t,Y);
plot(t)
plot(k)
plot(Y)
The data is used as a plot input variable in the form of a matrix, and multiple curves are drawn in one graph
You can try changing the t, k, and y variables in turn.
2. Attach a new image
Example 2 How to attach new graphics to the original image
% The above example is the premise
t=(0:pi/50:2*pi)';k=0.4:0.1:1;Y=cos(t)*k;plot(t,Y);
hold on
plot(t,Y+0.7)
plot(t,Y-0.5)
3. Lissajous graphics
%例3 用负数矩阵形式画李萨
clear
t=linspace(0,2*pi,80)';%生成80个等距采样线性间距向量\
X=[cos(t),cos(2*t),cos(3*t)]+1i*sin(t)*[1,1,1];%80x3的复数矩阵
plot(X)
axis square %使坐标轴长度相同
legend('1','2','3') %图例
4. Draw an ellipse
Example 4 Use the model 1*x^2/a^2 + y^2/(25-a^2) =1 to draw an ellipse
clear
th=[0:pi/50:2*pi]';
a=[0.5:.5:4.5];
X=cos(th)*a;
Y=sin(th)*sqrt(25-a.^2);
plot(X,Y),axis('equal'),xlabel('x'),ylabel('y')
title('A set of Ellipses')
legend('1','2','3')
Summarize