Filter löschen
Filter löschen

Fitting nonlinear model to data

1 Ansicht (letzte 30 Tage)
Sonisa
Sonisa am 5 Sep. 2018
Kommentiert: Sonisa am 5 Sep. 2018
I have been trying to fit nonlinear model to my data
Here are the codes:
X = [0.05 0.06 0.07 0.08 0.09 0.1 0.125 0.15 0.175 0.2 0.25 0.3 0.4 0.5 0.6 0.7 0.8 -0.1 -0.5 -0.8];%FAW40;
Y = [0.3 0.4 0.35 0.42 0.3 0.32 0.35 0.37 0.38 0.495 0.45 0.55 0.6 0.55 0.6 0.6 0.65 0.2 0.3 0.5]; %NDVI;
figure
% plot(FAW40_GS,NDVI_GS,'ok');
k = diff(x)<0; %select only data when the soil is drying
x = X(1:end,:);
y = Y(2:end,:);
plot(x(k(:,1),1),y(k(:,1),1),'ok')
hold all
plot(x(k(:,2),2),y(k(:,2),2),'+k')
plot(x(k(:,3),3),y(k(:,3),3),'dk')
set(gca,'XLim',[0 1])
set(gca,'XTick',(0:0.1:1))
%set(gca,'YLim',[0 1])
set(gca,'YTick',(0:0.1:1));
hold all
ylabel('\bf NDVI','fontsize',14);
xlabel('\bf FAW','fontsize',14);
slope = 0.2;
r = 0.40;
ypred = @(A, x)(A(1) ./ (A(2) + exp([(r-Y)*slope])));
A0 = [0.2;-0.5];
A1 = [ 0.3; -0.2];
opts = statset('nlinfit');
opts.RobustWgtFun = 'bisquare';
A_fit = nlinfit(x,y,ypred,A0,A1,opts);
hold all
plot(x',y','ko', x,ypred(A_fit,x'))
legend('Data','Fitted','location', 'northwest')
_But when I did I get the error
Error using nlinfit (line 185)
Requires a vector second input argument. Any help would be appreaciated.
_
  10 Kommentare
Matt J
Matt J am 5 Sep. 2018
Nope. Those lines will not execute
>> x = 0.637259937 0.621294757 0.672668532 0.521265646 0.421903196 0.549649009 0.312588087 0.28327584 0.359424364 0.253502479 0.253985122 0.313290724 0.209563459 0.2319699 0.274603618 0.156334057 0.183523167 0.236265826 0.475258711 0.560432822 0.629973282 0.238506777 0.253712482 0.302720237
x = 0.637259937 0.621294757 0.672668532 0.521265646 0.421903196 0.549649009 0.312588087 0.28327584 0.359424364 0.253502479 0.253985122 0.313290724 0.209563459 0.2319699 0.274603618 0.156334057 0.183523167 0.236265826 0.475258711 0.560432822 0.629973282 0.238506777 0.253712482 0.302720237
Error: Invalid expression. Check for missing multiplication operator, missing or unbalanced
delimiters, or other syntax error. To construct matrices, use brackets instead of
parentheses.
Sonisa
Sonisa am 5 Sep. 2018
Look at this file and hope it will works.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Genomics and Next Generation Sequencing finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by