How to linearly fit a semilog graph

34 visualizaciones (últimos 30 días)
Sonia Goyal
Sonia Goyal el 19 de Feb. de 2021
Comentada: Star Strider el 4 de Mzo. de 2021
Hello
I have my data file which is attached below. I have to plot this as semilog ( log scale on Y-axis) and have to linearly fit like the image attached. Please help me with the same

Respuestas (2)

Jonas
Jonas el 19 de Feb. de 2021
  1 comentario
Sonia Goyal
Sonia Goyal el 26 de Feb. de 2021
Thank you for your rresponse. But this isn't working for this data.

Iniciar sesión para comentar.


Star Strider
Star Strider el 26 de Feb. de 2021
Try this:
D1 = readmatrix('Data.xlsx');
x = D1(:,1);
y = D1(:,2);
[ymax,idx] = max(y);
idxrng = idx:numel(y);
objfcn = @(b,x,minlim) b(1).*exp(b(2).*x) + minlim;
B = fminsearch(@(b) norm(y(idxrng) - objfcn(b,x(idxrng),y(end))), [ymax; rand]);
figure
plot(x, y)
hold on
plot(x(idxrng), objfcn(B,x(idxrng),y(end)), '-r', 'LineWidth',1.5)
hold off
grid
set(gca, 'YScale','log')
It’s not easy to fit those data.
Using:
idxrng = 1:numel(y);
objfcn = @(b,x,minlim) b(1).*x.*exp(b(2).*x) + minlim;
instead, might be more accurate.
  4 comentarios
Sonia Goyal
Sonia Goyal el 4 de Mzo. de 2021
Thank you for you response.
Star Strider
Star Strider el 4 de Mzo. de 2021
My pleasure.

Iniciar sesión para comentar.

Categorías

Más información sobre Graphics Object Identification en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by