plot being generated is not in log space

2 views (last 30 days)
M K P Dev
M K P Dev on 15 Jul 2021
Commented: M K P Dev on 22 Jul 2021
I am plotting a curve for the following model:
fitfun = fittype(@(a0,a1,x) a0+(a1.*x));
The x and y values are log(x1) and log(y1). I have configures as YScale='log' and XScale='log'
y = [2.091666958,1.929444472,1.954580163,1.903415586,1.875379629,1.875379629,1.903415586,1.875379629,1.942330552,1.903415586,1.903415586,1.929750906,1.942330552]'
x = [7.163732175,7.009281649,5.203296758,7.0004477,7.087439702,7,7.012988611,7.002354474,5.274252552,5.38274806,7.000976802,7,5.321121833]'
UIAxes = uiaxes
UIAxes.XGrid = 'on';
UIAxes.YGrid = 'on';
UIAxes.XMinorGrid = 'on';
UIAxes.YMinorGrid = 'on';
UIAxes.YScale='log';
UIAxes.XScale='log';
starting_x = [1 1];
fitfun = fittype(@(a0,a1,x) a0+(a1.*x));
[fitobject,gof,output] = fit(x,y,fitfun,'StartPoint',starting_x);
fig = figure('Visible','off');
ax = axes(fig);
FigHandle = plot(fitobject,x,y,'or');
hApp = copyobj(FigHandle, UIAxes);
but still the plot which is being plotted is in linear scale and not log scale
I expect the output in log scale:

Accepted Answer

Cris LaPierre
Cris LaPierre on 15 Jul 2021
Edited: Cris LaPierre on 15 Jul 2021
That's an interesting way to get a plot into a UIAxes. Is there a reason why you don't just plot into it directly?
Your axes are still in log, but by default MATLAB sets the X and Y limits so that your data fills the graph. In your case, there is such little variance in your X and Y data that it looks linear. Set the X and Y limits to [1 10] to convince yourself they are still in log scale.
hApp = copyobj(FigHandle, UIAxes);
ylim(UIAxes,[1 10])
xlim(UIAxes,[1 10])
  3 Comments
M K P Dev
M K P Dev on 22 Jul 2021
thank you cris your answer cleared my doubt

Sign in to comment.

More Answers (0)

Tags

Products


Release

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!