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
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/23 21:54:03
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
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)
为什么解不出来解,但画图显示应该有解.
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
发现解在+/-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
可以:
clear all;clc;
for b=1:20;
a(b)=eval(solve('10+x=b','x'));
end
a =
Columns 1 through 13
-9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 ...
全部展开
可以:
clear all;clc;
for b=1:20;
a(b)=eval(solve('10+x=b','x'));
end
a =
Columns 1 through 13
-9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3
Columns 14 through 20
4 5 6 7 8 9 10
请采纳。
收起