绘图的模板
%********************绘图的标准程序************************
% y1 = sin(x);
% y2 = 2 *sin(x);
% figure('Name','名字','NumberTitle','off');
% subplot(2,1,1);
% plot(x,y1,'r');grid on ;
% xlabel('频率');
% ylabel('幅值');
% axis([-5,12,-3,3]);
% subplot(2,1,2);
% plot(x,y2,'bl');grid on ;
% axis([-5,12,-3,3]);
% xlabel('频率');
% ylabel('幅值');
%********************绘图的标准程序************************
生成离散时间信号
X = linspace(0,2*pi,50); %(起,尾,等分多少份)
Y = cos(X);
stem(X,Y)
绘制正弦信号
x = -pi:0.01:pi;
plot(x,sin(x)), grid on
绘制指数信号
X = -2:0.5:10;
Y = exp(X/2);
plot(X,Y); hold on ;
stem(X,Y);
阶跃函数
t = linspace(-10,10);
y = heaviside(t);
figure('Name','阶跃函数','NumberTitle','off');
plot(t,y,'y'); %黄色阶跃函数
hold on
syms x ;
fplot(heaviside(x-1),[-5,5],'r'); %红色右移的阶跃函数
%%%%%%%%%%%%%%%%%%%%%%%%%%%限制坐标轴显示%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%使用函数%%%
% inf 无穷大
% axis 设置轴范围和纵横比
%%%使用函数%%%
x = linspace(0,2*pi);
y = sin(x);
plot(x,y);
hold on ;
axis([0 2*pi -1.5 1.5]); %更改坐标轴范围,使 x 轴的范围从 到 ,y 轴的范围从 -1.5 到 1.5。
%%%%%%%%%%%%%%%%%%%%%%%%%%%限制坐标轴显示%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%设置命令行窗口输出显示格式%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%命令%%%
%format
%f = get(0,'Format') %获取当前数值格式
%S = get(0,'FormatSpacing') 获取当前行距,可以将其设为 loose 或 compact。
%%%命令%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%设置命令行窗口输出显示格式%%%%%%%%%%%%%%%%%%%%%%%%%%%%%