简体   繁体   English

使用MATLAB积分求解方程

[英]Solving equation with integration using MATLAB

I would like to solve an equation below using MATLAB: 我想使用MATLAB解决以下方程式:

在此处输入图片说明

All the parameters except p are known, so I only need to solve for p. 除p以外的所有参数都是已知的,因此我只需要求解p。 However since I need to consider the sign of the integrand and there is an absolute value sign in it I don't know how to solve it. 但是,由于我需要考虑被积数的正负号,并且其中有一个绝对值正负号,所以我不知道如何求解。 Could anyone please help? 谁能帮忙吗? Thank you. 谢谢。

This is an interesting question, so I'll give it a stab. 这是一个有趣的问题,因此我将对其进行介绍。 Just out of own curiosity, what equation is this? 只是出于好奇,这是什么方程式?

%This code just displays an error about not enough input arguments in line 4.  I'm still working on fixing this bug, but wanted to provide an update.
function y = yourFunc(m,q,t,p)
    if exist('p') == 0
        syms p
        fun = @(theta,p) ((1/pi) .* sign( 1 - p + (q .* sind(t))) .* (abs(1 - p + (q .* sind(t))) .^ m));
        eqn = (integral(@(theta)fun(theta,p),(-pi/2),(pi/2)) == 1);
        y = solve(eqn,p);
    end
end

function x = runCode()
    x = yourFunc(10,0.5,0:10:90)
end

Are your parameters vectors? 您的参数向量吗? I am unsure, but this code should work for elementwise operations anyway. 我不确定,但是此代码无论如何都应该适用于元素操作。 I also put 1/pi in the integrand since it's a constant and isn't integrated anyway. 我也将1 / pi放在了被积分数中,因为它是一个常数,并且无论如何都不会被积分。 Also, a caveat: I have never seen the "sign" function in your integrand so I put it in the code, but I'm not entirely sure what math symbol it is. 另外,请注意:我从未在您的被积函数中看到过“ sign”函数,因此我将其放入代码中,但是我不确定是什么数学符号。 I don't have MATLAB in front of me right now, but I think this should work; 我现在还没有MATLAB,但是我认为这应该可行。 if you have any problems with it please comment and I'll fix my code. 如果您有任何问题,请发表评论,我会修复我的代码。 Good luck with your project! 祝您项目顺利!

Solve Documentation , Integral Documentation 解决文档整体文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM