f=@(x,y)h-3.086*(x^2)-20.4082*(y^2);
q=integral2(f,-1/(30.864)^(1/2),1/(30.864)^(1/2),-1/(204.082)^(1/2),1/(204.082)^(1/2));
1. 需要给h赋值;
2. f函数中针对x和y的^操作需要改成 .^
h = 1;
f=@(x,y) h-3.086*(x.^2)-20.4082*(y.^2);
q=integral2(f,-1/(30.864)^(1/2),1/(30.864)^(1/2),-1/(204.082)^(1/2),1/(204.082)^(1/2))
结果:
q =
0.0470
已知q求h的办法,下面的函数文件存成funq.m文件
function q = funq(h)
f=@(x,y) h-3.086*(x.^2)-20.4082*(y.^2);
q=integral2(f,-1/(30.864)^(1/2),1/(30.864)^(1/2),-1/(204.082)^(1/2),1/(204.082)^(1/2));
求解m脚本文件
q = 0.5;
f = @(h) funq(h)-q;
h0 = 1;
h = fsolve( f,h0 )
结果:
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
<stopping criteria details>
h =
9.9873
验算:
>> f(h)
ans =
2.0365e-09
>> funq(h)
ans =
0.5000
f=@(x,y)h-3.086*(x^2)-20.4082*(y^2);
q=integral2(f,-1/(30.864)^(1/2),1/(30.864)^(1/2),-1/(204.082)^(1/2),1/(204.082)^(1/2));
您好,我是有问必答小助手,您的问题已经有小伙伴解答了,您看下是否解决,可以追评进行沟通哦~
如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~
ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>>https://vip.csdn.net/askvip?utm_source=1146287632