필터 지우기
필터 지우기

How to fit a linear line on a semilog plot?

조회 수: 4 (최근 30일)
Duncan Wright
Duncan Wright 2018년 4월 17일
편집: Duncan Wright 2018년 4월 17일
I'm struggling to fit a linear line on my log linear regression. Here is my code:
figure(2)
subplot(2,2,1)
[slope7, intercept7, MSE7, R27, S7, extra7] = logfit(totSPM,s2gbratio,'logx') % logfit is a function from the file exchange, uses semilogx.
fit7 = fitlm(log(totSPM),s2gbratio) % get x1/intercept/SE
hold on
% confiedence intervals. Highest line.
hx1 = (0.1546 + 0.036612); % get highest x1 value (x1 + SE)
hInt = (intercept7+0.077203); % get highest intercept value (intercept + SE)
x= linspace(0,10, 50); % Adapt n for resolution of graph
y= hx1*x + hInt; % highest confidence interval I want to plot as linear
plot(x,y,'b--') % plot highest confidence interval
As its on a semilog plot the output is a curve.
Is there any way round this ?
I've attached an image of my output using this code (sorry bout the volume bar... oops)
Kind regards, Duncan

답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear and Nonlinear Regression에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by