I was wondering if anyone knew how I could colour the area under the curve for the below code. I have tried to use area(Mu)
, however this returns a shaded area slightly different to the plot.
n=1;
a=[0:0.001:4];
A=(a.*n);
B=(n-n.*a);
C=(1-n);
Mu=(-B+sqrt((B.^2)-(4.*A.*C)))./(2.*A);
plot(a,Mu)
xlim([0 4])
ylim([0 .8])
plot
witharea
which gives you the linearea(a,Mu)
. This can be found in the documentation like this: «area(X,Y)
For vectorsX
andY
,area(X,Y)
is the same asplot(X,Y)
except that the area between0
andY
is filled.» – Mattplot
call is not the correct generic answer if the user wants to do something "special" with the boundary. The OP has triedarea
, so it's not like she's unaware that the function exists... – excazaplot
, she needs to callarea
afterhold on
or first plot the area and then the line. She triedarea(Mu)
but notarea(a,Mu)
... That's the reason why used the word replace to emphasize that the arguments are exactly the same. The citation corresponds to that as well. – Mattarea
as forplot
. I agree that I could have explained why it caused the wrong result. Namely because the x-axis does not match. BTW: I agree as well to this comment. – Matt