Borrar filtros
Borrar filtros

How to overlay a curve over histogram?

89 visualizaciones (últimos 30 días)
Chiara Petrillo
Chiara Petrillo el 26 de Abr. de 2017
Editada: Andrew Newell el 26 de Abr. de 2017
Hi There,
New to Matlab so sorry if the question is simple!
I have plotted a histogram with the following code:
data = csvread('testformatlab.csv')
col1 = data(:,8); %all rows in column 1
col2 = data(:,14);
X = (col1)./(col2);
histogram(X);
*I would like to overlay a curve to the histogram, similar to the red one in the attached image. My current histogram is shown in the blue image.
Thankyou!!!

Respuestas (1)

Andrew Newell
Andrew Newell el 26 de Abr. de 2017
Editada: Andrew Newell el 26 de Abr. de 2017
If you already have the curve, then just type hold on and plot it. An example:
ydata = randn(1000,1);
hist(ydata)
hold on
x = min(ydata):0.1:max(ydata);
y = 500*normpdf(x);
plot(x,y,'r')

Categorías

Más información sobre Histograms en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by