# Transfer Matrix Method - matlab

• MATLAB
Hi, I am working on evaluating electron transmissions through barriers using the transfer matrix method (like in optics) in matlab.

In the general simplest case, matching boundary conditions gives me two sets of equations:
Ax=By and Cy=Dz where A,B,C,D are 4x4 matrices and x,y,z are column vectors (4x1).

So by the transfer matrix method:
x=(A^-1)By and y=(C^-1)Dz so x={(A^-1)B(C^-1)D}z where the stuff inside the curly brackets is the transfer matrix (call it N).

Now at the moment, my code is N = inv(A)*B*inv(C)*D.

The issue is that for certain parameters, matlab returns that the matrix is nearly singular. It still calculates it and it seems to be fine most of the time (no goofy transmissions) but sometimes it just blows up. From what I have read, inverses isn't really something you do anyways in programming.

So my question is, how can I obtain my transfer matrix without taking inverses?

Matlab can solve equations of the form Ax=b, by the command x=A\b which I've read is far superior to taking inverses.The problem though is I have Ax=By and I don't want to multiply y into B.

In otherwords for the equations again: Ax=By and Cy=Dz, I would get x=A\(B*y) and y=C\(D*z) and so x=A\(B*C\(D*z)) but this is not a transfer matrix, this is a column vector since z has been multiplied into it. The whole point is to get the form x=Nz where x,z are the column vectors and N is the transfer matrix (4x4 in my case).

I am quite baffled by this whole thing, since I don't feel it should be difficult at all. Though my inexperience in computational physics is quite evident.

Any help would be MUCH appreciated.
Cheers!