Plotting results from "fitnlm" function

12 vues (au cours des 30 derniers jours)
Anant Sareen
Anant Sareen le 8 Déc 2021
Réponse apportée : KSSV le 8 Déc 2021
I am using the fitnlm function to obtain a regression curve for my experiements. I wanted to plot the results of the function on a 3D plot to graphically reperesent the results. I need help as to how that can be done. Please find below the excerpt of my code below. Thanks in advance.
X1 = [0 -5 -5 0 -10 -10 0 5 5 0 10 10 0 -5 5];
X2 = [0 0 5 5 0 10 10 0 -5 -5 0 -10 -10 -5 5];
X = [X1;X2].';
Torque = [15.64 21.15 14.34 13.29 22.83 14.17 9.18 14.63 21.5 24.21 13.04 25.47 28.66 26.68 12.4].
f = @(tb,x) tb(1) + tb(2)*x(:,1) + tb(3)* x(:,2)
opts = statset('Display','iter','TolFun',1e-20);
mdlfit = fitnlm(X, Torque,f, ones(3,1),'Options',opts)
Summary = [Torque predict(mdlfit,X) predict(mdlfit,X)-Torque]

Réponses (1)

KSSV
KSSV le 8 Déc 2021
x = Torque ;
y = predict(mdlfit,X) ;
Z = predict(mdlfit,X)-Torque ;
surf(x,y,Z)

Catégories

En savoir plus sur Time Series 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