Plotting over a histogram
Show older comments
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.
Accepted Answer
More Answers (0)
Categories
Find more on Noncentral t Distribution in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



