Home > Mobile >  semilogy, loglog do not work in order to set the y axis on a logarithmic scale
semilogy, loglog do not work in order to set the y axis on a logarithmic scale

Time:09-17

I am working on a numerical algorithm and I want to plot the error for 5 different shape parameters of my function. I want all the plots to figure on one same figure.

Here is the code that I use:

figure
hold on
for i=3:7
    [coord_ctrs, errors] = ApproxAdap1D(i);
    
    semilogy(coord_ctrs, (errors));
    title("Senkung des RMS Fehlers");
grid;
end

Result:

enter image description here

As you can see, it does not work, the y axis does not have a logarithmic scale. loglog function displays tthe same result too.

CodePudding user response:

The problem is with figure; hold on; that creates a linear figure, and you're adding subsequent plots to the linear axes.

You should set the axis to log explicitly.

Following on from How to make a log plot in matlab

set(gca,'XScale','log')

  • Related