我该如何求解先验方程? [英] how can I solve transcendental equation?

查看:114
本文介绍了我该如何求解先验方程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在matlab中求解给定的方程,以找到beta的值,但会出错.我在下面发布代码和错误.

I want to solve the given equation in matlab to find the value of beta but getting error. I am posting the code and error below.

谢谢.

n1=1.77;
n2=1.45;
d=1e-6;
lambda = 1e-6;
ko = 2*pi/lambda;
A=(ko*n1)^2;
B=(ko*n2)^2;
syms beta;
s = 'sqrt(A-beta^2)*(d/2)*tan(sqrt(A-beta^2)*d/2)=sqrt(beta^2-B)*(d/2)';
solve (s);

错误:

Error using solve>processString (line 337)
' sqrt(A-beta^2)*(d/2)*tan(sqrt(A-beta^2)*d/2)=sqrt(beta^2-B)*(d/2) ' is not a valid expression or equation.

Error in solve>getEqns (line 267)
   eqns = processString(eqns, v, vc);

Error in solve (line 150)
   [eqns,vars,options] = getEqns(varargin{:});

Error in transcendetal (line 9)
   solve (s); 

推荐答案

我确认R2013a的以下工作:

I confirm the following works on R2013a:

syms beta A B d

n1=1.77;
n2=1.45;
d=1e-6;
lambda = 1e-6;
ko = 2*pi/lambda;
A=(ko*n1)^2;
B=(ko*n2)^2;

solve ( sqrt(A-beta^2)*(d/2)*tan(sqrt(A-beta^2)*d/2)==sqrt(beta^2-B)*(d/2))

但是

Warning: Explicit solution could not be found.
> In solve at 179
ans =
[ empty sym ]

这很奇怪,因为在R2010a中,您使用上面提供的旧"语法,我得到了

This is odd, because in R2010a with the 'old' syntax you give above, I get

ans =
                                                                                                   0
 -(log((A + B - 2*beta^2 + 2*(A - beta^2)^(1/2)*(beta^2 - B)^(1/2)*i)/(A - B))*i)/(A - beta^2)^(1/2)

请注意,最后一个解决方案是复数值,这可能是您在更高版本中必须启用的某些选项.我仍然更喜欢白板方法:p

Note that this last solution is complex-valued, which might be some option you have to enable in later versions...I don't know the symbolic math toolbox very well; I still prefer the whiteboard method :p

这篇关于我该如何求解先验方程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆