作业帮 > 综合 > 作业

MATLAB解方程问题

来源:学生作业帮 编辑:拍题作业网作业帮 分类:综合作业 时间:2024/06/01 08:42:56
MATLAB解方程问题
syms n
lanmuda=1.55;
n1=1.6375696780514445567155543374853;
n2=1.6443618413936927969908352393948;
n3=1.6375696780514445567155543374853;
c1=n2^2/n1^2;
c2=n2^2/n3^2;
k0=2*pi/lanmuda;
r1=sqrt(n.^2-n1^2)*k0;
r2=sqrt(n2^2-n.^2)*k0;
r3=sqrt(n.^2-n3^2)*k0;
fun=r2.*5-atan(c1.*r1./r2)-atan(c2.*r3./r2)-pi;
solve(fun,n)
为什么解不出来解,但画图显示应该有解.
发现解在+/-1.6附近 因此通过fsolve 来解非线性方程,不能得到其解析解,只能计算其数值解,通过限制其精度,达到自己的要求.
 fsolve('funx',-1.7)即可求得 -1.6376 - 0.0000i fsolve('funx',1.5)           1.6376 + 0.0000ifunction [fx ] = funx( n )%FUNX Summary of this function goes here%   Detailed explanation goes herelanmuda=1.55;n1=1.6375696780514445567155543374853;n2=1.6443618413936927969908352393948;n3=1.6375696780514445567155543374853;c1=n2^2/n1^2;c2=n2^2/n3^2;k0=2*pi/lanmuda;r1=sqrt(n.^2-n1^2)*k0;r2=sqrt(n2^2-n.^2)*k0;r3=sqrt(n.^2-n3^2)*k0;fx=r2.*5-atan(c1.*r1./r2)-atan(c2.*r3./r2)-pi;
end