fastest way to apply A\B on each matrix page
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
hosein Javan
el 17 de Ag. de 2020
Comentada: hosein Javan
el 17 de Ag. de 2020
I would like to find an efficient fast way for calculating:
for i = 1:n
X(:,:,i) = A(:,:,i)\B(:,:,i)
end
where A and B are 10*10*n, and 10*1*n size matrices respectively. the matrices are large and must be called meny times. therefore I was thinking of replacing "for loops" with a faster way that does it very fast and not iteratively.
0 comentarios
Respuesta aceptada
Bruno Luong
el 17 de Ag. de 2020
Editada: Bruno Luong
el 17 de Ag. de 2020
Why insist on ARRAYFUN, your for-loop is perfectly fine. ARRAYFUN is a "vectoriztion" scam.
n = 100;
A = rand(10,10,n);
B = rand(10,1,n);
X = arrayfun(@(p) A(:,:,p)\B(:,:,p), 1:n, 'unif', 0);
X = cat(3,X{:});
5 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Operating on Diagonal Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!