How to fit a linear line on a semilog plot?

9 vues (au cours des 30 derniers jours)
Duncan Wright
Duncan Wright le 17 Avr 2018
Modifié(e) : Duncan Wright le 17 Avr 2018
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

Réponses (0)

Catégories

En savoir plus sur Linear and Nonlinear Regression dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by