anonymous function can't run

Hello!Here is my code:
miu2 =1 ; m=1;r1 = 19.69e-3 ; r2 = 27.44e-3 ; b = 9.94e-3; miu1 = 1 ; miu3 = 1 ; epis1 = 1 ; epis2 =2.1 ; epis3 = 1 ; n=1; c = 2.997925e8; z0 = 376.73415; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% dJ = @(m,x) m*besselj(m,x)/x-besselj(m+1,x); dY = @(m,x) m*bessely(m,x)/x-bessely(m+1,x); dI = @(m,x) m*besseli(m,x)/x+besseli(m+1,x); dK = @(m,x) m*besselk(m,x)/x-besselk(m+1,x); kzn = n*pi/b; k0 = @(f) 2*pi*f/c; k_rhon1 = @(f) sqrt(k0(f)*k0(f)*epis1*miu1-kzn*kzn) ; k_rhon2 = @(f) sqrt(k0(f)*k0(f)*epis2*miu2-kzn*kzn) ; k_rhon3 = @(f) sqrt(k0(f)*k0(f)*epis3*miu3-kzn*kzn) ; dZ_rho1 = @(f) z0*miu1*( k0(f)/k_rhon1(f) ); dZ_rho2 = @(f) z0*miu2*( k0(f)/k_rhon2(f) ); dZ_rho3 = @(f) z0*miu3*( k0(f)/k_rhon3(f) ); ddY_rho1 = @(f) epis1/z0*( k0(f)/k_rhon1(f) ); ddY_rho2 = @(f) epis2/z0*( k0(f)/k_rhon2(f) ); ddY_rho3 = @(f) epis3/z0*( k0(f)/k_rhon3(f) ); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% M11 = @(f) [dZ_rho1(f)*dI(m,-1i*k_rhon1(f)*r1)/besseli(m,-1i*k_rhon1(f)*r1)*besselj(m,k_rhon2(f)*r1)-1i*dZ_rho2(f)*dJ(m,k_rhon2(f)*r1), dZ_rho1(f)*dI(m,-1i*k_rhon1(f)*r1)/besseli(m,-1i*k_rhon1(f)*r1)*bessely(m,k_rhon2(f)*r1)-1i*dZ_rho2(f)*dY(m,k_rhon2(f)*r1) dZ_rho3(f)*dK(m,-1i*k_rhon3(f)*r2)/besselk(m,-1i*k_rhon3(f)*r2)*besselj(m,k_rhon2(f)*r2)-1i*dZ_rho2(f)*dJ(m,k_rhon2(f)*r2), dZ_rho3(f)*dK(m,-1i*k_rhon3(f)*r2)/besselk(m,-1i*k_rhon3(f)*r2)*bessely(m,k_rhon2(f)*r2)-1i*dZ_rho2(f)*dY(m,k_rhon2(f)*r2) ];
M12 = @(f) [m/r1*(kzn/k_rhon2(f)^2-kzn/k_rhon1(f)^2)*besselj(m,k_rhon2(f)*r1) , m/r1*(kzn/k_rhon2(f)^2-kzn/k_rhon1(f)^2)*bessely(m,k_rhon2(f)*r1) m/r2*(kzn/k_rhon2(f)^2-kzn/k_rhon3(f)^2)*besselj(m,k_rhon2(f)*r2) , m/r2*(kzn/k_rhon2(f)^2-kzn/k_rhon3(f)^2)*bessely(m,k_rhon2(f)*r2)];
M21 =@(f) M12(f);
M22 = @(f) [1i*ddY_rho2(f)*dJ(m,k_rhon2(f)*r1)-ddY_rho1(f)*dI(m,-1i*k_rhon1(f)*r1)/besseli(m,-1i*k_rhon1(f)*r1)*besselj(m,k_rhon2(f)*r1) ,1i*ddY_rho2(f)*dY(m,k_rhon2(f)*r1)-ddY_rho1(f)*dI(m,-1i*k_rhon1(f)*r1)/besseli(m,-1i*k_rhon1(f)*r1)*bessely(m,k_rhon2(f)*r1) 1i*ddY_rho2(f)*dJ(m,k_rhon2(f)*r2)-ddY_rho3(f)*dK(m,-1i*k_rhon3(f)*r2)/besselk(m,-1i*k_rhon3(f)*r2)*besselj(m,k_rhon2(f)*r2) ,1i*ddY_rho2(f)*dY(m,k_rhon2(f)*r2)-ddY_rho3(f)*dK(m,-1i*k_rhon3(f)*r2)/besselk(m,-1i*k_rhon3(f)*r2)*bessely(m,k_rhon2(f)*r2)];
FLSE =@(f) M11(f)-M12(f)/M22(f)*M21(f);
Eigen_FLSE = real( ( FLSE(1,1)*FLSE(2,2)-FLSE(1,2)*FLSE(2,1) ) );
r = Eigen_FLSE(10e9);
when I ran it.I got the message:
Error using @(f)M11(f)-M12(f)/M22(f)*M21(f) Too many input arguments.
Error in eigenfunctions (line 44) Eigen_FLSE = real( ( FLSE(1,1)*FLSE(2,2)-FLSE(1,2)*FLSE(2,1) ) );
Thanks!

 采纳的回答

You are giving two input arguments to a function that expects one.
FLSE =@(f) M11(f)-M12(f)/M22(f)*M21(f);
is declared to take a single argument, f.
Eigen_FLSE = real( ( FLSE(1,1)*FLSE(2,2)-FLSE(1,2)*FLSE(2,1) ) );
appears to call it with 2 arguments in each call.

5 个评论

But I want to calculate the determinant of FLSE.
How to program it?
I don't know what all your code is doing, you just asked about the error you were getting which seems to be caused by that.
Either you need to define your FLSE starting with:
@(f,g)
or similar - i.e. 2 arguments. Or you have to just pass 1 argument into your function.
No,I mean I want to get the elements of matrix FLSE by using my code:
Eigen_FLSE = real( ( FLSE(1,1)*FLSE(2,2)-FLSE(1,2)*FLSE(2,1) ) ).
But it thinks I call function FLSE.
FLSE =@(f) M11(f)-M12(f)/M22(f)*M21(f);
defines FLSE as a function. You have to call it with input (and output) to get a matrix out which is presumably the one you want to refer to by FLSE later on.
I use function det to solve it.It works! Thank you very much!

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by