m0_53140879
2021-06-11 18:40
采纳率: 100%
浏览 30

有大佬知道这个matlab代码哪里错了么?

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));

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • CSDN专家-Matlab_Fans 2021-06-11 19:07
    已采纳

    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
    
    已采纳该答案
    1 打赏 评论
  • m0_53140879 2021-06-11 18:48
    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));
    打赏 评论
  • 有问必答小助手 2021-06-15 17:19

    您好,我是有问必答小助手,您的问题已经有小伙伴解答了,您看下是否解决,可以追评进行沟通哦~

    如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~

    ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>>https://vip.csdn.net/askvip?utm_source=1146287632

    打赏 评论

相关推荐 更多相似问题