好久没登自己的网站了,看来我也是新潮澎湃一下子,图个新鲜,嗯,这样不好,以后要利用起来,多多记录,学习学习新的网络技术,在有限的时间,做出更多有意思的事情!!!
分类目录归档:wxcui.xyz往事(有损)
Sa(x) 函数绘图
%Sa函数生成及作图
x=-12*pi:0.01:12*pi;
y=sin(x)./x;
plot(x,y,'Color','blue');
hold on %在该图上继续绘图
xlabel('变量x的值');
ylabel('Sa(x)');
%图的范围
axis([-8*pi 8*pi -0.3 1.01]);
%坐标刻度
xticks([ -8*pi -4*pi -3*pi -2*pi -1.5*pi -1*pi -0.5*pi 0 ...
0.5*pi 1*pi 1.5*pi 2*pi 3*pi 4*pi 8*pi ]);
xticklabels({'-8\pi','-4\pi','-3\pi','-2\pi',...
'-1.5\pi','-1\pi','-0.5\pi','0','0.5\pi','1\pi','1.5\pi','2\pi',...
'3\pi','4\pi','8\pi'});
% 归一化Sa函数
x1=-12:0.01:12;
y1=sin(pi*x1)./(pi*x1);
plot(x1,y1,'Color','red');
legend('sin(x) / x','sin(\pix) / \pix');
%归一化函数的x轴
%参考 https://jingyan.baidu.com/article/0bc808fc0c41651bd485b905.html
ax2 = axes('Position',get(gca,'Position'),...
'XAxisLocation','top',...
'YAxisLocation','right',...
'Color','none',...
'XColor','r');
axis(ax2,[-8*pi 8*pi -0.3 1.01]);
xticks(ax2,[ -8*pi -12 -8 -4 -2 -1 0 1 2 4 8 12 8*pi ]);
xticklabels(ax2,{'-8\pi','-12','-8','-4',...
'-2','-1','0','1','2','4','8',...
'12','8\pi'});
% 图中的格线显示
grid on;
%最小值标注
ymin=min(y);
line([-12*pi 12*pi], [ymin ymin],'Color','green');
% y=0所在轴
line([-12*pi 12*pi], [0 0],'Color','black');
text(3*pi,0.6,'最小值为绿色线处:-0.2172');
title('Sa(x) 和 Sa(\pix)函数');
hold off