一维高斯函数
一维高斯函数MATLAB代码:
% 程序初始化
clear all; close all; clc;
randn('seed',0);
%%一维高斯函数
% 生成均值为0,标准差为1的一维高斯概率密度函数
mu=0;
sigma=1;
x=-6:0.1:6;
y=normpdf(x,mu,sigma);
figure;
plot(x,y);
绘制一维高斯函数
二维高斯函数
二维高斯函数MATLAB代码
%%二维高斯函数
% 程序初始化
clear all; close all; clc;
randn('seed',0);
% 主程序
figure;
mu=[0 0];
sigma=[0.3 0;0 0.35];
[x y]=meshgrid(linspace(-8,8,80)',linspace(-8,8,80)');
X=[x(:) y(:)];
z=mvnpdf(X,mu,sigma);
surf(x,y,reshape(z,80,80));hold on;
%再生成一个
figure;
mu=[4 0];
sigma=[1.2 0;0 1.85];
[x y]=meshgrid(linspace(-8,8,80)',linspace(-8,8,80)');
X=[x(:) y(:)];
z=mvnpdf(X,mu,sigma);
surf(x,y,reshape(z,80,80));
二维高斯函数绘图