我想使用 MATLAB 求解下面的方程:
除了p之外的所有参数都是已知的,所以我只需要求解p。然而,由于我需要考虑被积函数的符号并且其中有一个绝对值符号,所以我不知道如何解决它。有人可以帮忙吗?谢谢你。
这是一个有趣的问题,所以我会尝试一下。出于自己的好奇,这是什么方程式?
%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
你的参数是向量吗?我不确定,但无论如何,这段代码应该适用于元素操作。我还将 1/pi 放入被积函数中,因为它是常数并且无论如何都不会积分。另外,需要注意的是:我从未在被积函数中见过“符号”函数,因此我将其放入代码中,但我不完全确定它是什么数学符号。我现在面前没有 MATLAB,但我认为这应该可行;如果您有任何问题,请发表评论,我将修复我的代码。祝您的项目顺利!