Clear Filters
Clear Filters

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

1 view (last 30 days)
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

Accepted Answer

Torsten
Torsten on 8 Jul 2022
Edited: Torsten on 8 Jul 2022
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 Comments
Torsten
Torsten on 8 Jul 2022
Edited: Torsten on 8 Jul 2022
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.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!