r1374065
2020-05-11 12:19
采纳率: 100%
浏览 474

Matlab多参数拟合,为什么我这个算出来是复数?

x1=NDVI;
x2=VV;
x3=VH;
y=VWC;

n=length(y);
str=num2str([1:n]');
X=[x1,x2,x3];
fx1=@(b,x1,x2,x3)b(1)*exp(b(2)*x1)+b(3)*exp(b(4)*x2)+ b(5)*exp(b(6)*x2)+b(7);
fx2=@(b,X) b(1)*exp(b(2)* X(:,1))+b(3)*exp(b(4)* X(:,2))+ b(5)*exp(b(6)* X(:,3))+b(7);
b=[1 2 3 4 5 6 7];
for l=1:5
    b=lsqcurvefit(fx2,b,X,y);
    b=nlinfit(X,y,fx2,b);
end
b

另外 据说有算拟合初值的程序?
下面是我的数据
NDVI VV VH VWC
0.367567568 -12.5698329 -19.00852024 0.266198422
0.601058551 -12.21928522 -19.42093998 0.918703318
0.44537428 -14.27199702 -21.22621166 0.635368421
0.394254324 -13.75161415 -20.52673149 0.414315789
0.380969794 -14.66715876 -21.78026874 0.457263158
0.333382581 -13.96920831 -20.56267627 0.29174533
0.347142647 -14.72184822 -22.36435001 0.327122323
0.342167467 -14.06451663 -23.53390449 0.386390272
0.332461114 -14.02065141 -21.95493924 0.206453545
0.37972283 -14.50587908 -22.00263251 0.327738265
0.34964483 -13.52347147 -20.8585261 0.293778543
0.372049334 -13.55826598 -20.91720918 0.407708672
0.489375721 -13.08946636 -21.4454566 0.736015517
0.324213618 -13.19440778 -21.56038194 0.486547366
0.362637363 -13.18809614 -20.67733792 0.588068182
0.437490046 -12.62493919 -20.92979035 0.419618984
0.419501134 -13.49582508 -20.38569888 0.669284759
0.456582633 -12.94909986 -21.04778624 0.722678317
0.443275213 -11.04512259 -18.40759252 0.682552961
0.357626756 -13.49058113 -20.58293328 0.27179959
0.60387169 -11.91861033 -19.84253492 0.836839607
0.544650412 -9.531325868 -19.37691463 0.591828934
0.290620778 -10.91812441 -19.41796874 0.335389562
0.390346112 -11.25622217 -19.59060797 0.061828727
0.483056957 -9.33826645 -20.31287823 0.269907927
0.2763094 -14.68770235 -21.92750537 0.101147532
0.375008673 -11.76157755 -18.6924758 0.279222168
0.43277592 -11.52288315 -19.69964053 0.439792015
0.658512957 -9.853464212 -16.76401222 0.637488285
0.580268035 -9.913134889 -16.93776403 1.015012456
0.060258458 -10.56239152 -17.7399537 0.299132653
0.358727665 -7.281353556 -13.99840508 0.774259259
0.056415172 -10.59651588 -18.2928017 0.554936133
0.222659323 -8.904902978 -17.15664032 0.880481829
0.1875 -9.205197728 -16.37551833 0.789573703
0.184653602 -12.86773978 -19.17365762 0.815445476
0.525773196 -10.00704476 -17.14340543 1.301862965
0.559869036 -11.20539971 -17.2419588 1.142806268
0.701734751 -10.73855501 -16.78980186 1.423785204
0.56175582 -10.2854917 -16.66782731 2.300828176
0.497889108 -11.63014311 -17.80902691 1.112640609
0.539530426 -10.37045684 -17.37491957 1.843084487
0.792702766 -12.98008461 -21.67104227 1.956459755
0.762190728 -13.27018744 -21.50795637 3.488644689
0.755530726 -10.37074442 -17.96817748 3.71093245
0.728071749 -10.97450829 -20.98883473 2.531217911
0.709747607 -10.66086624 -18.41778073 2.256000448
0.64443453 -11.92426821 -18.13370497 1.706343815
0.714548803 -10.21053499 -17.65596367 2.816241201
0.303764706 -10.34567991 -18.44312721 1.770311095
0.268877437 -10.3890121 -17.90789635 1.563639607
0.520744597 -9.692957038 -17.72963957 3.118764723
0.717602996 -11.33614114 -19.21564571 2.852965235
0.783679589 -12.03161286 -16.48444476 2.862197053
0.77985851 -10.41054068 -18.92986865 4.221873861
0.782064872 -10.51416089 -17.28196251 3.188305395
0.761270731 -10.72329123 -17.60653715 3.066611247
0.724796275 -12.31311148 -20.94675355 1.429373472
0.775485437 -11.32607003 -18.97385547 3.186505414
0.758081335 -9.438552955 -16.2820129 4.057738378
0.778037383 -10.00322018 -16.00841162 2.334117886
0.796577207 -10.63318202 -17.57952527 3.527744982
0.808084624 -10.2419665 -18.46687989 4.15353467
0.812776215 -10.89578598 -21.6186462 3.779050319
0.801742498 -10.46905157 -18.78521901 4.147703325
0.783806344 -10.42756389 -18.00251403 2.515034895
0.792722813 -9.954934241 -16.22320278 3.428184782
0.76473029 -10.30806511 -15.81511273 2.632649304
0.831480109 -10.88788894 -15.96120042 3.31466011
0.84863124 -9.42331158 -14.18447518 5.940083306
0.801769912 -9.795795446 -15.4192279 2.770243044
0.796214789 -10.1841912 -16.18313039 4.116228801
0.824180791 -9.437112169 -15.10663893 4.334416835
0.786832511 -10.89668816 -16.13224316 2.873315796
0.748613678 -9.471403731 -15.54024548 3.090226679
0.74908648 -10.71693884 -15.56824506 3.574774197
0.81772659 -10.26541377 -16.57086252 3.275911837
0.822093304 -8.717064742 -15.0609659 4.814944561
0.803993694 -9.465452286 -15.67148193 6.05835985
0.855038578 -7.281826403 -13.45196351 3.649416765
0.824225636 -7.217892863 -14.69516246 6.737846673
0.830444075 -8.592348503 -14.77855442 5.740742483
0.810486715 -8.967969097 -15.19543033 7.841563231
0.835863378 -8.637816026 -14.60965199 5.789512575
0.824667169 -6.508767085 -13.95351957 5.223367375
0.842718928 -8.154232608 -14.30458726 6.995585413
0.857039711 -8.943021043 -15.5038524 5.355741669
0.821656051 -8.861357633 -15.30607485 7.927631342
0.821908449 -8.08759868 -15.5437058 6.926179356
0.853987445 -8.696096161 -14.93056835 7.222468827
0.826337251 -9.180255429 -14.4554464 9.278749496
0.842314488 -9.695369424 -15.34088286 4.12691852
0.866573687 -8.993719877 -14.07591274 6.394803714
0.790783898 -7.436550512 -14.595838 4.574697658

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dabocaiqq 2020-05-12 09:26
    已采纳

    因为出现了负数开根号的情况,所以就是复数

    1 打赏 评论
  • FF_NL 2021-08-31 16:26

    请问最后是如何解决的呢?我也是用最小二乘法拟合曲线,求解出来的拟合参数应当是个实数,但是拟合出来参数也为复数

    打赏 评论

相关推荐 更多相似问题