Say I have some matrix 3×3 matrix, A, that is defined as:
for ii = 1:length(layers+1) A(ii) = [k0^2*eO(ii)-ky^2-kz^2,k0^2*eH(ii)+kx*ky,kx*kz; kx*ky-k0^2*eH(ii),k0^2*eO(ii)-kx^2-kz^2,ky*kz; kx*kz,ky*kz,k0^2*eE(ii)-kx^2-ky^2];end
I am defining every variable in this matrix except for "kz". I'm trying to solve where the determinant of A is equal to zero. The catch is i don't want to use some variation of:
syms kzkz = solve(det(A) == 0,kz);
because this is a function that is called several hundred thousand times through my main code and I would like to avoid using syms as it is slow.
Now, I've read up on a function called fsolve() and can't seem to figure out how to pass in the known variables of A to this section of code:
fun = @det0x0 = zeros(4,1);kz = fsolve(fun,x0);function F = det0(kz)F = det([k0^2*eO-ky^2-kz^2,k0^2*eH+kx*ky,kx*kz; kx*ky-k0^2*eH,k0^2*eO-kx^2-kz^2,ky*kz; kx*kz,ky*kz,k0^2*eE-kx^2-ky^2]);
Let me know if you need more information to help solve this problem. Thanks!
Best Answer