MATLAB解方程问题
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.0000i
function [fx ] = funx( n )
%FUNX Summary of this function goes here
% Detailed explanation goes here
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;
fx=r2.*5-atan(c1.*r1./r2)-atan(c2.*r3./r2)-pi;
end