help me about nlinfit
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Garon0927
le 16 Mar 2018
Réponse apportée : Prajit T R
le 19 Mar 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 commentaires
Réponse acceptée
Prajit T R
le 19 Mar 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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur 회귀 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!