Hello, I am trying to shade an area under the curve of a lognormal pdf between two vertical lines. Here is the code to help you generate the problem:
pd = makedist('Lognormal','mu',3.323167914007358,'sigma',0.241878609884653)r = random(pd,1000,1); % generate 1000 numbers from the distribution
ix = linspace(min(r),max(r)); % to scale the graph
y = pdf(pd, ix);figureplot(ix,y)hold on;line([20, 20], ylim, 'LineWidth', 2, 'Color', 'r');hold on;line([24, 24], ylim, 'LineWidth', 2, 'Color', 'r');
This is the picture of the plot above:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/191211/image.jpeg)
I tried searching, but the best answer I have come up with fills the area between the lines all the way to the top of the graph, while I want it to end at the curve. Also, I want the lines to stop at the curve, not stretch beyond it. Here is a google picture of what I am trying to achieve:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/191212/image.png)
Best Answer