필터 지우기
필터 지우기

How to linearly fit a semilog graph

조회 수: 11 (최근 30일)
Sonia Goyal
Sonia Goyal 2021년 2월 19일
댓글: Star Strider 2021년 3월 4일
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

답변 (2개)

Jonas
Jonas 2021년 2월 19일
  댓글 수: 1
Sonia Goyal
Sonia Goyal 2021년 2월 26일
Thank you for your rresponse. But this isn't working for this data.

댓글을 달려면 로그인하십시오.


Star Strider
Star Strider 2021년 2월 26일
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
Sonia Goyal
Sonia Goyal 2021년 3월 4일
Thank you for you response.
Star Strider
Star Strider 2021년 3월 4일
My pleasure.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Graphics Object Identification에 대해 자세히 알아보기

태그

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by