Solving equation with two variables, and giving the result for one as a function of the other

1 次查看(过去 30 天)
I have an equation with two variables (Alpha, and Ze_grad), i wont an equation that locks like Alpha= f(Ze_grad), but i cant do that!
mfreqs=[200 5000];
syms Alpha Ze_grad
Zm = 1./((2i*pi*mfreqs).^Alpha);
Zm_grad = (imag(Zm(2))-imag(Zm(1)))/(real(Zm(2))-real(Zm(1)));
equ= Zm_grad - Ze_grad == 0 ;
alpha = solve(equ, Alpha)
Warning: Unable to find explicit solution. For options, see help.
alpha = Empty sym: 0-by-1

采纳的回答

Torsten
Torsten 2022-7-8
编辑:Torsten 2022-7-8
Alpha0 = 2.0;
Ze_grad = 3.0;
Alpha = fsolve(@(x)fun(x,Ze_grad),Alpha0)
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.
Alpha = 1.2048
fun(Alpha,Ze_grad)
ans = 1.1813e-13
function res = fun(Alpha,Ze_grad)
mfreqs=[200 5000];
Zm = 1./((2i*pi*mfreqs).^Alpha);
Zm_grad = (imag(Zm(2))-imag(Zm(1)))/(real(Zm(2))-real(Zm(1)));
res = abs(Zm_grad - Ze_grad);
end
  9 个评论
Torsten
Torsten 2022-7-8
编辑:Torsten 2022-7-8
Depends on your problem. If mfreqs is the same for many Alpha-calulations, I think the interpolation will be quite fast compared to binary search. If mfreqs often changes and Zm_grad has to be built anew, you might be correct.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Equation Solving 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by