×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

plot problem. I'm new in MatLab

plot problem. I'm new in MatLab

plot problem. I'm new in MatLab

(OP)
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

RE: plot problem. I'm new in MatLab

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
http://www.geocities.com/bstex2001/

Joe
The new BSTeX- Equation viewer for Matlab7
http://www.geocities.com/bstex2001

RE: plot problem. I'm new in MatLab

(OP)
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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources