Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

plot problem. I'm new in MatLab

Status
Not open for further replies.

dannG

Computer
Mar 15, 2005
2
Hy
This are my .m files. It draws the normal curve.

The problem: I need to shade area under the curve in interval -3:3. I don't know how. Pls help.

Lab.m
Code:
disp('Introduceti valoarea minima pe care doriti sa o reprezentati')
%vi=input('val minima:')
vi=-4
disp('Introduceti valoarea maxima pe care doriti sa o reprezentati')
%vf=input('val maxima:')
vf=4
fplot('Z_func', [vi vf])

title('Reprezentarea grafica a functiei normale')

Z_func.m
Code:
function [R]= Z_func(XX)
R=(1/sqrt(2*pi))*exp(-(XX^2)/2);

Thanks
dan

 
Replies continue below

Recommended for you

Hi,
Find the curve intersection with the vertical lines x=-3 and x=3: j1 and j2 (indices);
Create 2 vectors 1) Y1=[0 y(j1:j2) 0]; % [x, y] original vectors
2) X1=[ -3 x(j1:j2) 3];
Use fill.m :
hold on
fill(X1,Y1,[0.8 0.8 0.8]);

I hope this helps.

Joe Sababa

The new BSTeX - Equation viewer for Matlab7

Joe
The new BSTeX- Equation viewer for Matlab7
 
Hy joe3,
Thanks for the tip! The magic word is "hold on". That's because I used your method without hold on and my figure was redrawing for every plot, line, fill function ... .
Thanks again!
dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor