搜索内容 搜索用户

# [未答复] lsqcuverfit函数拟合多元变量函数后画图

ggtt 发表于 2021-11-18 16:30:00
 参数用下面的代码可以求出来，xdata(:,4:9)是代表时间时间，怎么画出以时间为x轴以F为y轴的拟合后的曲线呢？ function F=myfun(k,xdata) F=(xdata(:,1).*exp(-xdata(:,3)*k(1)/k(2))+xdata(:,2)./xdata(:,3)/k(1).*(1-exp(-k(1)/k(2)*xdata(:,3)))).*exp(-k(1)/k(2).*(xdata(:,4:9)-xdata(:,3))); end clc clear all x = [1.1,1.1,1,1.8,2.2,0.5,1,0.6,0.9,0.2,5,2.7,1.1,2.1,1.7,0.2,1.5,1.5,1,1,2,1.7,1.4,1.4,0.9,2,3.7,0.5,5.4,1;     1000,1500,1500,1000,1250,1000,1000,500,1250,1000,3000,750,1000,1000,1000,2000,2000,1500,750,500,4000,750,1500,1000,1000,1000,1500,500,1000,750;     1,2,2,2,4,1,2,1,2,1,2,1,2,2,1,2,5,3,3,4,1,5,1,3,2,2,1,1,1,2;     58,68,68,68,67,69,59,59,71,70,70,63,70,69,54,65,69,71,70,68,79,75,71,62,59        ,60,56,60,61,63; 196,202,207,179,176,179,179,172,192,188,189,176,196,194,176,184,204,203,203,201,196,188,179,188,184,183,183,182,184,186; 538,542,540,525,524,546,537,535,529,516,514,507,525,523,506,517,554,552,553,550,543,533,524,529,531,521,513,519,519,534; 1463,1440,1438,1476,1473,1480,1474,1472,1472,1468,1465,1457,1450,1451,1439,1493,1464,1464,1459,1459,1484,1490,1475,1496,1492,1492,1487,1490,1491,1460; 2887,2886,2888,2911,2909,2904,2901,2896,2913,2909,2907,2901,2893,2891,2872,2932,2905,2904,2909,2917,2923,2934,2924,2935,2931,2931,2922,2929,2931,2908; 4852,4862,4863,4844,4844,4835,4827,4825,4852,4858,4846,4842,4843,4843,4827,4364,4346,4345,4349,4350,4355,4372,4353,4375,4372,4371,4365,4369,4369,4344]; xdata=x.'; ydata = [93.5,92.1,86.2,68.1,93.5,80.2,91.8,66.2,87.1,79.6,147.2,89.1,96.8,93.9,111.1,83.7,87.1,107.6,93.9,105.2,76.2,116.2,96.7,85.7,78.9,112.7,81.9,67.5,92.4,85.3;     75.5,70.2,65.2,53.8,94.2,60.7,80.8,48.9,73.9,57.2,133.9,90.5,76.2,82.1,98.1,81.8,71.4,125.5,68.8,83.3,67.8,95.9,75.4,72.7,61.4,92.4,68,53.1,85.7,72.3;     46,44.1,42.9,36.3,54.1,41.8,49.9,30.3,46.5,32.9,89.1,57.2,52.5,56,59.8,45,42.2,68.3,35.1,46.6,36.6,64.2,45.4, 45.4,37,64.6,51.6,34.5,61.4,46.1;     24.4,16.4,17.4,18.6,26.6,18.9,25.5,10,21.3,7,53.2,23.5,26,26.4,27.9,15.9,14.8,21.9,11.3,21.9,17,33.1,20.7, 19.3,13.7,26.9,28,10.1,36.5,20.6;     7.3,3.9,4.4,7.1,8.5,4.9,9.7,2.1,5.5,0.7,22.7,6.6,9.3,9.1,9.7,3.4,3.7,5.6,2.4,6.8,5.5,12.5,6.1, 6.1,3.2,7.3,9.4,2.6,17.2,6.3;     4.3,2.5,2.7,4.3,6.9,2.9,6.4,1,3.2,0.3,17.1,4.8,6.1,6.4,6,0.5,1.8,1.9,0.8,2.2,2.7,4.7,2.2, 2,1.1,2.9,4.1,1.2,8.6,2.1]; y=ydata.';     k0 = [2,10]; [k,resnorm]=lsqcurvefit(@myfun,k0,xdata,y);
 您需要登录后才可以回帖 登录 | 注册 本版积分规则 回帖后跳转到最后一页