Shift sheets of matrix individually without loop
1 次查看(过去 30 天)
显示 更早的评论
I've seen this question a couple of times, but the questions seemed to be old, and used arrayfun which seems like just another loop to me.
I have a 3D array of numeric data, and a 1D array of integers that I want to use to shift each sheet of the 3D array, say in the second dimension.
A = randi(100,10,10,10);
shift = randi(10,10,1);
B = nan(size(A));
% Example of single shift
B(:,:,1) = circshift(A(:,:,1),[0, shift(1),0]);
Is it possible to do all sheets at once without a for loop for each sheet, or using arrayfun?
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!