Using solve function in order to solve 2 equation with 2 uknowns
Show older comments
Hello,
I've tried to solve the 2 following equations:
n0^2*kx*tan(kx*a-(p-1)*pi/2)-n1^2*gx=0
gx^2+kx^2-k0^2*(n1^2-n0^2)=0
for the unknown kx and gx. all the other symbols are known parameters.
I've used the following code:
syms kx gx n0 n1 p a k0
[kx,gx]=solve(n0^2*kx*tan(kx*a-(p-1)*pi/2)-n1^2*gx, gx^2+kx^2-k0^2*(n1^2-n0^2))
It didn't work well. Can someone help?
David
2 Comments
Mohammad Monfared
on 11 Nov 2013
I've run your code and there is no problem!
kx =
(- gx^2 + k0^2*n1^2 - kx^2)^(1/2)/k0
-(- gx^2 + k0^2*n1^2 - kx^2)^(1/2)/k0
gx =
(2*(atan((gx*k0^2*n1^2)/(kx*(gx^2 - k0^2*n1^2 + kx^2))) + a*kx))/pi + 1
(2*(atan((gx*k0^2*n1^2)/(kx*(gx^2 - k0^2*n1^2 + kx^2))) + a*kx))/pi + 1
any message from matlab?
david ohana
on 11 Nov 2013
Answers (2)
Roger Stafford
on 11 Nov 2013
0 votes
I think you need to include the two variables you regard as unknown as arguments in the 'solve' function. Otherwise it has no way to know which are the unknowns. See its documentation.
Walter Roberson
on 11 Nov 2013
0 votes
There will be a number of solutions, in pairs, spaced approximately Pi/a apart, confined to the range kx in +/- sqrt(k0^2*n1^2-k0^2*n0^2). (This does imply that with a chosen "a", you could reduce it down to a single pair of solutions... I would have to look further to see if there are circumstances under which there would be no solutions at all.)
Categories
Find more on Symbolic Math Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!