
Q: Efficient multidimensional matrix handling
Posted:
May 16, 2005 6:33 AM


Hello everybody,
I have implemented the algorithm displayed at http://qucs.sourceforge.net/tech/node5.html to convert a S matrix (as generated by an Agilent network analyer, in Touchstone format) into a Z impedance matrix (see below). However, I *suspect* that this would be much more efficient using a threedimensional matrix instead of the "for" loop, a single command to do the actual calculation, and return a 2x2xf matrix, where "f" is the number of samples.
But I'm not sure how to do that  and how to work with a matrix like this (like matrix multiplication etc). Can anybody help out? I'm using Matlab 14.1 (SP2) under Linux (SuSE 9.1 / 9.3). I looked at various Matlab FAQs on the Web but couldn't find anything related to working with (N>2)dimensional matrices.
Thank you!
My code:
% % [f, Z11,Z12,Z21,Z22] = S2P2Z(f, S11,S12,S21,S22, Z0); % % formula: Z = Gref * (ES)^1 * (S * Zref + Zref*) * Gref % % Z = result matrix % S = input matrix % E = identity matrix % Gref = E * 1/(2*sqrt(Re(Z_0))) % Zref = E * Z_0 %
function [f, Z11,Z12,Z21,Z22] = S2P2Z(Z0, fS11,fS12,fS21,fS22)
S_11 = dlmread(fS11, '', 6, 0); S_12 = dlmread(fS12, '', 6, 0); S_21 = dlmread(fS21, '', 6, 0); S_22 = dlmread(fS22, '', 6, 0);
f = S_11(:,1); f = f'; S11 = S_11(:,2)+i.*S_11(:,3); S12 = S_12(:,2)+i.*S_12(:,3); S21 = S_21(:,2)+i.*S_21(:,3); S22 = S_22(:,2)+i.*S_22(:,3);
E = eye(2,2); Gref = E .* 1/(2.* sqrt(abs(real(Z0)))); Zref = E .* Z0; for t = 1:size(S11,1), S = [S11(t) S12(t); S21(t) S22(t)]; Z = inv(Gref) * inv(ES) * (S * Zref + conj(Zref)) * Gref; Z11(t) = Z(1,1); Z12(t) = Z(1,2); Z21(t) = Z(2,1); Z22(t) = Z(2,2); end
end
 Jens Benecke http://www.hitchhikers.de  Europas kostenlose Mitfahrzentrale seit 1998 http://www.rbhosting.de  Webhosting mit Extras  PHP ab ?9  SSH ab ?19 http://www.spamfreemail.de  100% saubere Postfächer, garantiert!

