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
Z_func.m
Thanks
dan
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')
%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);
R=(1/sqrt(2*pi))*exp(-(XX^2)/2);
Thanks
dan





RE: plot problem. I'm new in MatLab
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
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