Plotting results from "fitnlm" function

12 次查看(过去 30 天)
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]

回答(1 个)

KSSV
KSSV 2021-12-8
x = Torque ;
y = predict(mdlfit,X) ;
Z = predict(mdlfit,X)-Torque ;
surf(x,y,Z)

类别

Help CenterFile Exchange 中查找有关 Time Series 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by