matlab中 sqrt(1+(cos(x))^2)的积分

问题描述:

matlab中 sqrt(1+(cos(x))^2)的积分
>> fun=inline('sqrt(1+(cos(x))^2)')
fun =
Inline function:
fun(cos,x) = sqrt(1+(cos(x))^2)
>> [R,k,T]=Romberg(fun,realmin,4,1e-6)
Error using ==> inline.subsref
Not enough inputs to inline function.
Error in ==> Romberg at 13
T=h/2*(fun(a)+fun(b));
>> syms x
>> fun=sqrt(1+(cos(x))^2)
fun =
(1+cos(x)^2)^(1/2)
>> [R,k,T]=Romberg(fun,0,4,1e-6)
Subscript indices must either be real positive integers or logicals.
Error in ==> Romberg at 13
T=h/2*(fun(a)+fun(b));
1个回答 分类:综合 2014-09-27

问题解答:

我来补答
fun=inline('sqrt(1+(cos(x).^2)')
这里x是向量 要用点乘或者点幂
fun=inline('sqrt(1+(cos(x).^2))')
fun =
Inline function:
fun(x) = sqrt(1+(cos(x).^2))
>> [R,T]=Romberg(fun,[0 4],1e-6)
R =
4.9666
T =
5.2178 0 0 0 0 0 0
4.7752 4.6276 0 0 0 0 0
4.9314 4.9834 5.0072 0 0 0 0
4.9578 4.9667 4.9656 4.9649 0 0 0
4.9645 4.9667 4.9667 4.9667 4.9667 0 0
4.9661 4.9666 4.9666 4.9666 4.9666 4.9666 0
4.9665 4.9666 4.9666 4.9666 4.9666 4.9666 4.9666
 
 
展开全文阅读
剩余:2000
上一页:单调性最小值
下一页:溶质质量