matlab符号积分的时候,算出来的值是一个有理分数,怎么化为小数
>>clear>>p=[-1,1,0,0,1];>>r=roots(p);>>symsty>>y=-t^4+t^3+1;>>a=r(4),b=r(1)a=-0.8192b...
>> clear
>> p=[-1,1,0,0,1];
>> r=roots(p);
>> syms t y
>> y=-t^4+t^3+1;
>> a=r(4),b=r(1)
a =
-0.8192
b =
1.3803
>> S=int(y,t,a,b)
S =
111075182471752207232543365209043723582334876804232938082696627732229888661685/57896044618658097711785492504343953926634992332820282019728792003956564819968
>> 展开
>> p=[-1,1,0,0,1];
>> r=roots(p);
>> syms t y
>> y=-t^4+t^3+1;
>> a=r(4),b=r(1)
a =
-0.8192
b =
1.3803
>> S=int(y,t,a,b)
S =
111075182471752207232543365209043723582334876804232938082696627732229888661685/57896044618658097711785492504343953926634992332820282019728792003956564819968
>> 展开
2个回答
展开全部
可以用eval或double将其强制转换为数值类型:
>> p=[-1,1,0,0,1];
>> r=roots(p);
>> syms t y
>> y=-t^4+t^3+1;
>> a=r(4);b=r(1);
>> S=int(y,t,a,b)
S =
568704934255371301030622029870605341246289411397194775051131423230050797740313363/296427748447529460284341721622241044104371160744039843941011415060257611878236160
>> format long g
>> eval(S)
ans =
1.91852799622785
>> double(S)
ans =
1.91852799622785
用vpa也可以,而且得到的结果精度比eval和double高,但需要注意的是,其结果仍然是sym类型:
>> vpa(S)
ans =
1.9185279962278480837035997945132
>> whos ans
Name Size Bytes Class
ans 1x1 190 sym object
Grand total is 34 elements using 190 bytes
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询