用matlab求解数值积分
用matlab求解数值积分函数:
function du=eqns2(x,u)
du=zeros(4,1);
du(1)=u(2); du(2)=u(3);
du(3)=u(4);
du(4)=-3/[u(2)*u(4)/u(1)-u(3)/u(1)^4+u(2)^2/u(1)^5-
... 1/((u(1)+1)*u(1)^3)];
命令窗口:
y0=; =ode45('eqns2',,y0);
我想求num_y2(:,1)(也就是u(x))在区间的积分怎么办? 怎么写函数?
用quad计算积分,需要给出函数名, I=quad('num_y2(:,1)',1,10) 这样写就出错了
回复 楼主 zhihaikou 的帖子
num_y2(:,1)是什么 用trapz即可 num_y2(:,1)是什么——————————————
num_y2(:,1)是求解的函数
num_y2(:,2)是求解函数的二阶导数
依此类推
回复 板凳 messenger 的帖子
直接trapz('num_y2(:,1)',1,10)
??? >> trapz('num_y2(:,1)',1,10)
??? Error using ==> trapz
LENGTH(X) must equal the length of the DIM'th dimension of Y.
回复 地板 zhihaikou 的帖子
我问的是里面的东西数据?
把他贴出来 自己看看帮助trapz怎么用,很简单
最讨厌告诉命令以后,再问命令怎么用了
原帖由 zhihaikou 于 2008-9-22 12:45 发表 http://www.chinavib.com/forum/images/common/back.gif
>> trapz('num_y2(:,1)',1,10)
??? Error using ==> trapz
LENGTH(X) must equal the length of the DIM'th dimension of Y. x =
0
3.4276e-026
6.8552e-026
1.0283e-025
1.3710e-025
3.0848e-025
4.7986e-025
6.5124e-025
8.2262e-025
1.6795e-024
2.5364e-024
3.3933e-024
4.2502e-024
8.5347e-024
1.2819e-023
1.7104e-023
2.1388e-023
4.2811e-023
6.4233e-023
8.5656e-023
1.0708e-022
2.1419e-022
3.2130e-022
4.2842e-022
5.3553e-022
1.0711e-021
1.6067e-021
2.1422e-021
2.6778e-021
5.3556e-021
8.0334e-021
1.0711e-020
1.3389e-020
2.6778e-020
4.0167e-020
5.3556e-020
6.6945e-020
1.3389e-019
2.0084e-019
2.6778e-019
3.3473e-019
6.6945e-019
1.0042e-018
1.3389e-018
1.6736e-018
3.3473e-018
5.0209e-018
6.6945e-018
8.3682e-018
1.6736e-017
2.5105e-017
3.3473e-017
4.1841e-017
8.3682e-017
1.2552e-016
1.6736e-016
2.0920e-016
4.1841e-016
6.2761e-016
8.3682e-016
1.0460e-015
2.0920e-015
3.1381e-015
4.1841e-015
5.2301e-015
1.0460e-014
1.5690e-014
2.0920e-014
2.6151e-014
5.2301e-014
7.8452e-014
1.0460e-013
1.3075e-013
2.6151e-013
3.9226e-013
5.2301e-013
6.5376e-013
1.3075e-012
1.9613e-012
2.6151e-012
3.2688e-012
6.5376e-012
9.8064e-012
1.3075e-011
1.6344e-011
3.2688e-011
4.9032e-011
6.5376e-011
8.1720e-011
1.6344e-010
2.4516e-010
3.2688e-010
4.0860e-010
6.5860e-010
9.0860e-010
1.1586e-009
1.4086e-009
1.6586e-009
1.9086e-009
2.1586e-009
2.4086e-009
2.6586e-009
2.9086e-009
3.1586e-009
3.4086e-009
3.6586e-009
3.9086e-009
4.1586e-009
4.4086e-009
4.6586e-009
4.9086e-009
5.1586e-009
5.4086e-009
5.6586e-009
5.9086e-009
6.1586e-009
6.4086e-009
6.6586e-009
6.9086e-009
7.1586e-009
7.4086e-009
7.6586e-009
7.9086e-009
8.1586e-009
8.4086e-009
8.6586e-009
8.9086e-009
9.1586e-009
9.4086e-009
9.5565e-009
9.7043e-009
9.8522e-009
1.0000e-008
num_y2 =
1.7182e-009 0 0 0
1.7182e-0099.8369e-0578.6097e-0315.0238e-005
1.7182e-0097.8695e-0563.4439e-0301.0048e-004
1.7182e-0092.6560e-0557.7488e-0301.5071e-004
1.7182e-0096.2956e-0551.3776e-0292.0095e-004
1.7182e-0097.1711e-0546.9739e-0294.5214e-004
1.7182e-0092.6993e-0531.6875e-0287.0333e-004
1.7182e-0096.7471e-0533.1081e-0289.5452e-004
1.7182e-0091.3599e-0524.9592e-0281.2057e-003
1.7182e-0091.1573e-0512.0672e-0272.4616e-003
1.7182e-0093.9862e-0514.7147e-0273.7176e-003
1.7182e-0099.5448e-0518.4384e-0274.9735e-003
1.7182e-0091.8755e-0501.3238e-0266.2295e-003
1.7182e-0091.5186e-0495.3381e-0261.2509e-002
1.7182e-0095.1461e-0491.2043e-0251.8789e-002
1.7182e-0091.2223e-0482.1438e-0252.5069e-002
1.7182e-0092.3901e-0483.3524e-0253.1348e-002
1.7182e-0091.9167e-0471.3431e-0246.2747e-002
1.7182e-0096.4739e-0473.0236e-0249.4146e-002
1.7182e-0091.5352e-0465.3768e-0241.2554e-001
1.7182e-0092.9991e-0468.4026e-0241.5694e-001
1.7182e-0092.4004e-0453.3621e-0233.1394e-001
1.7182e-0098.1028e-0457.5655e-0234.7093e-001
1.7182e-0091.9208e-0441.3451e-0226.2792e-001
1.7182e-0093.7518e-0442.1017e-0227.8491e-001
1.7182e-0093.0017e-0438.4074e-0221.5699e+000
1.7182e-0091.0131e-0421.8917e-0212.3548e+000
1.7182e-0092.4015e-0423.3631e-0213.1398e+000
1.7182e-0094.6904e-0425.2548e-0213.9248e+000
1.7182e-0093.7524e-0412.1020e-0207.8496e+000
1.7182e-0091.2664e-0404.7294e-0201.1774e+001
1.7182e-0093.0020e-0408.4079e-0201.5699e+001
1.7182e-0095.8632e-0401.3137e-0191.9624e+001
1.7182e-0094.6906e-0395.2550e-0193.9248e+001
1.7182e-0091.5831e-0381.1824e-0185.8872e+001
1.7182e-0093.7525e-0382.1020e-0187.8496e+001
1.7182e-0097.3291e-0383.2844e-0189.8121e+001
1.7182e-0095.8633e-0371.3137e-0171.9624e+002
1.7182e-0091.9789e-0362.9559e-0172.9436e+002
1.7182e-0094.6906e-0365.2550e-0173.9248e+002
1.7182e-0099.1613e-0368.2109e-0174.9060e+002
1.7182e-0097.3291e-0353.2844e-0169.8121e+002
1.7182e-0092.4736e-0347.3898e-0161.4718e+003
1.7182e-0095.8633e-0341.3137e-0151.9624e+003
1.7182e-0091.1452e-0332.0527e-0152.4530e+003
1.7182e-0099.1614e-0338.2109e-0154.9060e+003
1.7182e-0093.0920e-0321.8475e-0147.3590e+003
1.7182e-0097.3291e-0323.2844e-0149.8121e+003
1.7182e-0091.4315e-0315.1318e-0141.2265e+004
1.7182e-0091.1452e-0302.0527e-0132.4530e+004
1.7182e-0093.8649e-0304.6186e-0133.6795e+004
1.7182e-0099.1614e-0308.2109e-0134.9060e+004
1.7182e-0091.7893e-0291.2830e-0126.1325e+004
1.7182e-0091.4315e-0285.1318e-0121.2265e+005
1.7182e-0094.8312e-0281.1547e-0111.8398e+005
1.7182e-0091.1452e-0272.0527e-0112.4530e+005
1.7182e-0092.2367e-0273.2074e-0113.0663e+005
1.7182e-0091.7893e-0261.2830e-0106.1325e+005
1.7182e-0096.0390e-0262.8866e-0109.1988e+005
1.7182e-0091.4315e-0255.1318e-0101.2265e+006
1.7182e-0092.7958e-0258.0185e-0101.5331e+006
1.7182e-0092.2367e-0243.2074e-0093.0663e+006
1.7182e-0097.5487e-0247.2166e-0094.5994e+006
1.7182e-0091.7893e-0231.2830e-0086.1325e+006
1.7182e-0093.4948e-0232.0046e-0087.6657e+006
1.7182e-0092.7958e-0228.0185e-0081.5331e+007
1.7182e-0099.4359e-0221.8042e-0072.2997e+007
1.7182e-0092.2367e-0213.2074e-0073.0663e+007
1.7182e-0094.3685e-0215.0115e-0073.8328e+007
1.7182e-0093.4948e-0202.0046e-0067.6657e+007
1.7182e-0091.1795e-0194.5104e-0061.1499e+008
1.7182e-0092.7958e-0198.0185e-0061.5331e+008
1.7182e-0095.4606e-0191.2529e-0051.9164e+008
1.7182e-0094.3685e-0185.0115e-0053.8328e+008
1.7182e-0091.4744e-0171.1276e-0045.7493e+008
1.7182e-0093.4948e-0172.0046e-0047.6657e+008
1.7182e-0096.8257e-0173.1322e-0049.5821e+008
1.7182e-0095.4606e-0161.2529e-0031.9164e+009
1.7182e-0091.8429e-0152.8190e-0032.8746e+009
1.7182e-0094.3685e-0155.0115e-0033.8328e+009
1.7182e-0098.5322e-0157.8305e-0034.7910e+009
1.7182e-0096.8257e-0143.1322e-0029.5821e+009
1.7182e-0092.3037e-0137.0475e-0021.4373e+010
1.7182e-0095.4606e-0131.2529e-0011.9164e+010
1.7182e-0091.0665e-0121.9576e-0012.3955e+010
1.7182e-0098.5324e-0127.8306e-0014.7912e+010
1.7182e-0092.8797e-0111.7619e+0007.1871e+010
1.7182e-0096.8260e-0113.1324e+0009.5833e+010
1.7182e-0091.3332e-0104.8946e+0001.1980e+011
1.7182e-0091.0671e-0091.9584e+0012.3975e+011
1.7182e-0093.6020e-0094.4087e+0013.5999e+011
1.7182e-0098.5407e-0097.8433e+0014.8067e+011
1.7182e-0091.6690e-0081.2266e+0026.0194e+011
1.7182e-0097.0159e-0083.1998e+0029.7815e+011
1.7182e-0091.8476e-0076.1265e+0021.3655e+012
1.7182e-0093.8467e-0071.0040e+0031.7686e+012
1.7182e-0096.9524e-0071.4986e+0032.1918e+012
1.7182e-0091.1431e-0062.1021e+0032.6402e+012
1.7182e-0091.7561e-0062.8213e+0033.1189e+012
1.7182e-0092.5640e-0063.6645e+0033.6332e+012
1.7182e-0093.5993e-0064.6414e+0034.1892e+012
1.7183e-0094.8968e-0065.7631e+0034.7931e+012
1.7183e-0096.4941e-0067.0425e+0035.4519e+012
1.7183e-0098.4324e-0068.4942e+0036.1732e+012
1.7183e-0091.0757e-0051.0135e+0046.9651e+012
1.7183e-0091.3517e-0051.1983e+0047.8368e+012
1.7183e-0091.6768e-0051.4061e+0048.7982e+012
1.7183e-0092.0569e-0051.6391e+0049.8603e+012
1.7183e-0092.4986e-0051.9000e+0041.1035e+013
1.7183e-0093.0095e-0052.1919e+0041.2337e+013
1.7183e-0093.5975e-0052.5181e+0041.3779e+013
1.7183e-0094.2717e-0052.8822e+0041.5379e+013
1.7183e-0095.0421e-0053.2885e+0041.7156e+013
1.7183e-0095.9198e-0053.7416e+0041.9128e+013
1.7183e-0096.9172e-0054.2467e+0042.1320e+013
1.7184e-0098.0480e-0054.8096e+0042.3755e+013
1.7184e-0099.3274e-0055.4367e+0042.6461e+013
1.7184e-0091.0772e-0046.1352e+0042.9471e+013
1.7184e-0091.2402e-0046.9131e+0043.2817e+013
1.7185e-0091.4236e-0047.7791e+0043.6537e+013
1.7185e-0091.6299e-0048.7434e+0044.0675e+013
1.7185e-0091.8617e-0049.8168e+0044.5278e+013
1.7186e-0092.1218e-0041.1012e+0055.0397e+013
1.7187e-0092.4134e-0041.2341e+0055.6090e+013
1.7187e-0092.7401e-0041.3821e+0056.2423e+013
1.7188e-0093.1059e-0041.5469e+0056.9466e+013
1.7189e-0093.5151e-0041.7301e+0057.7300e+013
1.7190e-0093.9727e-0041.9341e+0058.6013e+013
1.7191e-0094.4840e-0042.1610e+0059.5702e+013
1.7191e-0094.8142e-0042.3071e+0051.0194e+014
1.7192e-0095.1667e-0042.4626e+0051.0857e+014
1.7193e-0095.5429e-0042.6283e+0051.1564e+014
1.7194e-0095.9444e-0042.8048e+0051.2317e+014 原帖由 messenger 于 2008-9-22 14:02 发表 http://www.chinavib.com/forum/images/common/back.gif
自己看看帮助trapz怎么用,很简单
最讨厌告诉命令以后,再问命令怎么用了
那个命令需要给出函数
我这个是求出来的数值解
最后得到这个数值解在该区间上的积分 trapz就是求数值解积分的
你在哪看到trapz命令需要给出函数的???:@o
原帖由 zhihaikou 于 2008-9-22 14:08 发表 http://www.chinavib.com/forum/images/common/back.gif
那个命令需要给出函数
我这个是求出来的数值解
最后得到这个数值解在该区间上的积分 原帖由 messenger 于 2008-9-22 14:16 发表 http://www.chinavib.com/forum/images/common/back.gif
trapz就是求数值解积分的
你在哪看到trapz命令需要给出函数的???:@o
谢谢老兄了 明白了 搞定了
页:
[1]