MATLAB visualization (1) basic function visualization

 1. Discrete function

        The discrete sequence on the graph only reflects the functional relationship in certain effective intervals, and cannot express the functional relationship in infinite intervals.

eg: graphical representation of discrete functionsy=\left | \left ( n-6 \right ) \right |^{-1}

%MATLAB可视化
%1---离散函数可视化,y=|(n-6)|^-1
clc
clear
n=0:15;
y=1./abs(n-6);
plot(n,y,'m*','MarkerSize',10)
grid on

 2. Continuous function visualization

      Like discrete function visualization, continuous function visualization must first calculate the corresponding function value on a set of discrete independent variables, and represent this set of data pairs with points.

(1) Separate the interval finely and use more points to express the continuity of the function; 

(2) Connect the two points with a straight line.

eg:y=sin(t)sin(9t) 

%连续函数可视化
t1=(0:11)/11*pi;  %自变量
y1=sin(t1).*sin(9*t1); %对应的函数值
t2=(0:100)/100*pi;
y2=sin(t2).*sin(9*t2);
%接下来绘图并将子图放于一起
subplot(2,2,1),plot(t1,y1,'r.'),axis([0,pi,-1,1]),title('子图(1)')
subplot(2,2,2),plot(t2,y2,'b.'),axis([0,pi,-1,1]),title('子图(2)')
subplot(2,2,3),plot(t1,y1,t1,y1,'r.'),axis([0,pi,-1,1]),title('子图(3)')
subplot(2,2,4),plot(t2,y2),axis([0,pi,-1,1]),title('子图(4)')

Guess you like

Origin blog.csdn.net/m0_73982095/article/details/130388887