Applying array of transform matrices to array of vectors
1 view (last 30 days)
Show older comments
I have a large array of 3x3 transform matrices, e.g. 3x3x700 that I would like to apply to a corresponding array of 3x1 vectors e.g. 3x1x700 to obtain an array of transformed vectors. Is there a way of vectorising this operation that is more efficient than using a for loop?
Thanks,
Steve
0 Comments
Accepted Answer
Paul
on 26 Apr 2023
Check out pagemtimes. Whether or not it's faster than a loop ... would need to be tested on your system
D = rand(3,3,700);
v = rand(3,1,700);
tic,y = pagemtimes(D,v);toc
z = 0*y;
tic
for ii = 1:700
z(:,1,ii) = D(:,:,ii)*v(:,1,ii);
end
toc
isequal(z,y)
More Answers (0)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!