making y axis logarithmic in Matlab

821 Views Asked by At

I have written the following code in MuPAD. And now I tried to plot "Pb versus sigmas" in Matlab using "semilogy" command. But my Y-axis is still linear, it did not change to logarithmic scale.

Any suggestion as to fix this is highly appreciated.

N:= 2;
d:= 1*10^3;
a:= 5*10^-2;
ap:= 8.1;
be:= 4;
b0:= 0.25;
rhom:= 0.1;
g:= 2*b0*(1-rhom);
ohm:= 0.5;
f:= ohm + 2*(b0)*rhom;
A:= ((2*(ap)^(ap/2))/((g^(1+(ap/2)))*gamma(ap)))*(((g*be)/(g*be+f))^(be+(ap/2)));

a_k:= (binomial(be-1,k-1)/gamma(k))*((g*be+f)^(1-(k/2)))*((f/g)^(k-1))*(ap/be)^(k/2);
ad:= 0.6;
v:= (sqrt(PI)*a)/(sqrt(2)*ad);
ae:= float(sqrt((ad^2*sqrt(PI)*erf(v))/(2*v*exp(-v^2))));
//sigmas:= 0.05;
z:= ae/(2*sigmas);
x:= (z^2/(1+z^2));
//pt:= 140*10^-3;
//R:= 0.5;
//sigman:= 10^-7;
//Ao:= erf^2(v);
//U_i := ((pt^2*R^2)/(2*sigman^2))*Ao^2*x^2*(g+f)^2;
Y:= (ap^2*be^2*x^2*(g+f)^2)/(16*100*((g*be)+f)^2);
pb:= (1/2)*sum(((z^2*A*a_k*(2^(ap+k-4)))/PI)*(((ap*be)/(g*be+f))^(-((ap+k)/2)))*meijerG(5,1,[1,(2+z^2)/2],[(z^2)/2,ap/2,(1+ap)/2,k/2,(1+k)/2],Y),k=1..be);
S2:= hfarray(1..5,[pb $ sigmas=1..5]);

My pb values are:

[0.3340089062, 0.4380877868, 0.4676408486, 0.4799658727, 0.4862966796]

Expected vs actual outcome:

enter image description here

1

There are 1 best solutions below

3
On

Actually, without converting your variables to a logarithmic scale before plotting them or using the semilogy plot, you can achieve the result you want by using the following command:

set(gca,'YScale','log');

once the plot (a traditional plot created through the plot function) has been created.