MATLAB: I need to plot a function that contains parameters. I do not get an error, yet the figure does not depict a graphic, it is just blank. How to produce a visible graph

functionparameterplotting

function Y=myfun(X)
X=linspace(0,10,100);
H=10
p1=(9.98*10^(-1))
p2=(1.293*10^(-3))
Y=(((X.^(2))*(0.5*p1-0.5*p2)+(0.5*(H.^(2))*p2))/(X*(p1-p2)+H*p2));
plot(X,Y);
xlabel("Height x of substance wiht \rho_1");
ylabel("Height f(x)");

Best Answer

Change the line
Y=(((X.^(2))*(0.5*p1-0.5*p2)+(0.5*(H.^(2))*p2))/(X*(p1-p2)+H*p2));
to
Y=(((X.^(2))*(0.5*p1-0.5*p2)+(0.5*(H.^(2))*p2))./(X*(p1-p2)+H*p2));
You do not need to program a loop.