histogram and plot at the same

조회 수: 19 (최근 30일)
cgo
cgo 2015년 1월 13일
댓글: cgo 2015년 1월 14일
Hello,
Please help. I want to draw a plot of a function (the ones we have when we use plot()) and a histogram (with the bins) in the same graph (superimposed on each other).
Any ideas on how to achieve this?
Thanks

채택된 답변

Sean de Wolski
Sean de Wolski 2015년 1월 13일
histogram(randn(1000,1))
hold on
plot(-6:6,abs(sin(-6:6)*100))
In R2014b. In R2014a and earlier use hist() instead of histogram.
  댓글 수: 1
cgo
cgo 2015년 1월 14일
Hi again.
My histogram is actually 'drawing itself', constantly updating in a for loop with the following flow:
x_axis = -10:0.05:10;
for t =1:50
hist(x(:,t),x_axis);
ylim([0,n]);
xlim([-10,10]);
pause(0.1)
drawnow;
end
the vector x and the value n are known beforehand. As the histogram is updating itself, I want my graph to be there superimposed.
I attempted to insert the lines you introduced in this message, but I keep on receiving an error message.
Thanks for your help.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Histograms에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by