如何在 Matlab 中生成服从正态分布但 w.r.t. 时间的数字



随着时间沿x轴移动,输出值(可能是频率或概率(相应地显示,即随着时间的移动,值应该最初增加直到平均值,然后减少。我预先指定了平均值 mu=10 和标准差西格玛 = 2。

你的意思是你想绘制一个高斯函数吗?我不确定你是否也想要某种动画。如果没有,您可以修改下面的代码以关闭修改。

clear; close all; clc;
% Set the mean and standard deviation
mu = 10;
sigma = 2;
% Time t
t = linspace(0,20,101);
% The equation for a normal distribution
f = 1/(sqrt(2*pi)*sigma)*exp( -(t-mu).^2/(2*sigma^2));
hold on;
xlim([0,20]);
ylim([0,0.25]);
axis manual;
for i=1:length(t)
    plot( t(1:i), f(1:i), 'b-');
    pause(0.1);
end
hold off;

最新更新