help me about nlinfit
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Garon0927
am 16 Mär. 2018
Beantwortet: Prajit T R
am 19 Mär. 2018
i want to solve nonlinear regression problem. input variable 'x' is two element. also output variable 'T' = two element.
but An error has occurred in matlab.
how can i solve it.
help me.....
here is my code.
clear all close all clc;
x(1,:) = 0:1:100; x(2,:) = 100:1:200; v = [4 8 5 3 ]; mdl = @(b,t)( b(1)*t.^3 + b(2)*t.^2 + b(3)*t + b(4)); T = mdl(v,x); S = mdl(v,x) + 10000*randn(1,101); beta0 = [0 0 0 0]; beta = nlinfit(x,S,mdl,beta0); %beta %result = mdl(beta,x);
figure(1) grid on hold on
plot(S','ro') %plot(result)6
0 Kommentare
Akzeptierte Antwort
Prajit T R
am 19 Mär. 2018
Hi Kim
The second argument to the nlinfit function only accepts a vector. So it would be better to fit 'x' element-wise. I have modified your code to illustrate the same. I am not sure if this is what you're looking for, but this might help:
x(1,:) = 0:1:100;
x(2,:) = 100:1:200;
v = [4 8 5 3 ];
mdl = @(b,t)( b(1)*t.^3 + b(2)*t.^2 + b(3)*t + b(4));
T = mdl(v,x);
S = mdl(v,x) + 10000*randn(1,101);
beta0 = [0 0 0 0];
size(x)
size(S)
beta1 = nlinfit(x(1,:),S(1,:),mdl,beta0);
beta2 = nlinfit(x(2,:),S(2,:),mdl,beta0);
result = mdl([beta1 beta2],x);
figure(1)
grid on
hold on
plot(S','ro')
figure
plot(result)
Cheers
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu 회귀 finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!