利用 MATLAB 绘制正态分布曲线

利用 MATLAB 绘制正态分布曲线

欢迎学习交流!
邮箱: z…@1…6.com
网站: https://zephyrhours.github.io/

声明:
下面代码基于Matlab 2018b,如果您的论文中使用了该代码,请添加引用:
Zengfu Hou, Wei Li, Ran Tao, Pengge Ma, and Weihua Shi. Collaborative Representation with Background Purification and Saliency Weight for Hyperspectral Anomaly Detection[J]. SCIENCE CHINA Information Sciences. 2020.

正文

论文中漂亮的正态分布曲线其实也可以通过matlab中的代码来实现,下面代码奉上。

 Author: Zephyr Hou
% 2020-09-26
%% Main Function
clc;clear;close all;

x=-4:0.01:4;
y=gaussmf(x,[1,0]);
plot(x,y,'b','LineWidth',2);hold on;
axis([-4 4 0 1.001])

%% 置信区间边界
plot([-2,-2],[0,gaussmf(-2,[1,0])],'k','LineWidth',2);hold on
plot([2,2],[0,gaussmf(2,[1,0])],'k','LineWidth',2);hold on
%% 置信区间颜色填充
for i=1:floor(length(x)/4)
    plot([x(i),x(i)],[0,gaussmf(x(i),[1,0])],'Color',[0.35,0,0.6],'LineWidth',2);hold on 
end
for i=1:floor(length(x)/4)
    ind=x(x>2);
    plot([ind(i),ind(i)],[0,gaussmf(ind(i),[1,0])],'Color',[0.35,0,0.6],'LineWidth',2);hold on 
end
%% 图中标注设置
set(gca,'XTicklabel',{' ',' ','\mu-2\sigma',' ','\mu',' ','\mu+2\sigma',' '},'fontsize',15)
set(gca,'YTicklabel',[])
annotation('arrow',[0.27,0.30],[0.24,0.20],'LineWidth',2)
annotation('arrow',[0.76,0.73],[0.24,0.20],'LineWidth',2)
text(-3,0.20,'\alpha/2=0.025','color','r','fontsize',15)
text(2.1,0.20,'\alpha/2=0.025','color','r','fontsize',15)

title('The 95% confidence interval for \mu','fontsize',15)

通过拉伸图像窗口,可以获得下面显示效果:
在这里插入图片描述

  • 6
    点赞
  • 63
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

独不懂

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值