MATLAB用fsolve解方程H=1.90;lanmuda=1.55;n1=1.55;n2=1.67;n3=1.50;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=@(n)(r2*H-atan(r1/r2)-atan(r3/r2))s= fsolve(fun,1.60)错误信息如下:fun = @(n)(r2*H-atan(r1/r
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/27 12:54:44
MATLAB用fsolve解方程H=1.90;lanmuda=1.55;n1=1.55;n2=1.67;n3=1.50;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=@(n)(r2*H-atan(r1/r2)-atan(r3/r2))s= fsolve(fun,1.60)错误信息如下:fun = @(n)(r2*H-atan(r1/r
MATLAB用fsolve解方程
H=1.90;
lanmuda=1.55;
n1=1.55;
n2=1.67;
n3=1.50;
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=@(n)(r2*H-atan(r1/r2)-atan(r3/r2))
s= fsolve(fun,1.60)
错误信息如下:
fun =
@(n)(r2*H-atan(r1/r2)-atan(r3/r2))
错误使用 fsolve (line 256)
FSOLVE requires all values returned by user functions to be of data type double.
出错 m11 (line 14)
s= fsolve(fun,1.60)
不要用solve,用slove我会解.
MATLAB用fsolve解方程H=1.90;lanmuda=1.55;n1=1.55;n2=1.67;n3=1.50;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=@(n)(r2*H-atan(r1/r2)-atan(r3/r2))s= fsolve(fun,1.60)错误信息如下:fun = @(n)(r2*H-atan(r1/r
fsolve要求所有内容都是double型,你这里r1,r2,r3
是sym变量,所以出错,改为下面:
f = @(n)sqrt(n2^2-n^2)*k0*H-atan(sqrt(n^2-n1^2)*k0/(sqrt(n2^2-n^2)*k0))-atan(sqrt(n^2-n3^2)*k0/(sqrt(n2^2-n^2)*k0));
>> fsolve(f,1.6)
fsolve要求所有内容都是double型,你这里r1,r2,r3
是sym变量,所以出错,改为下面:
f = @(n)sqrt(n2^2-n^2)*k0*H-atan(sqrt(n^2-n1^2)*k0/(sqrt(n2^2-n^2)*k0))-atan(sqrt(n^2-n3^2)*k0/(sqrt(n2^2-n^2)*k0));
>> fsolve(f,1.6)好,我...
全部展开
fsolve要求所有内容都是double型,你这里r1,r2,r3
是sym变量,所以出错,改为下面:
f = @(n)sqrt(n2^2-n^2)*k0*H-atan(sqrt(n^2-n1^2)*k0/(sqrt(n2^2-n^2)*k0))-atan(sqrt(n^2-n3^2)*k0/(sqrt(n2^2-n^2)*k0));
>> fsolve(f,1.6)
收起