Plotting over a histogram
显示 更早的评论
Hi all,
So I am trying to plot a normal curve over a histogram but the curve doesn't appear. Here is the code:
clear all, close all, clc
%% Defining the simulation parameters
N = 10000;
M = 30;
alpha = 0.7;
%Finding the uniformly distributed random numbers
phi = unifrnd(-pi, pi,1,N);
%Defining the function for random variable x
x = cos(phi);
%Initializing and Finding the output sequence Y through the difference equation
y = zeros(1, N);
y(1) = x(1);
for i = 2:N
y(i) = y(i-1)*alpha + x(i);
end
figure(1)
edges = [-3:0.2:3];
p2 = histogram(y, edges);
hold on
norm = normpdf(edges, 0,1);
plot(edges, norm)
hold off
Any help would be appreciated, thank you.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Noncentral t Distribution 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




