speed up a matlab code by replacing inv(X)*Y with X\Y in 3D dimensions

hi,
I want to speed up my code by replacing inv(X)*Y with X\Y. The main issue is that X is a 3D matrix. In details, i have the following matrixes:
A = 380; B = 380; C = 200; D=1;
X = rand(A,B,C) +1i*rand(A,B,C); X2 = zeros(A,B,C);
tic;
for m=1:C
X2(:,:,m) = inv(X(:,:,m));
end
toc; % inverting the matrix X costs about 4.44 ~ 4.74 sec
Y = rand(A,1) + 1i*rand(A,1);
Z = reshape(reshape(permute(X2, [2 1 3]), [A B*C]), [B A*C]).' * Y;
Z = permute(reshape(Z.',[D A C]),[2 1 3]);
Output = zeros(A,C);
Output(:,:) = Z(:,1,:);
Basically i'm doing Z = inv(X)*Y on a 3D scale, Is there any simpler way to skip the for loop and use \ inside the Z= line without the need of X2=inv(X) and for ??
X, Y, X2 and Z are complex matrixes
Thanks in advance.

Categories

Find more on Fourier Analysis and Filtering in Help Center and File Exchange

Asked:

on 11 Sep 2012

Community Treasure Hunt

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

Start Hunting!