Shift sheets of matrix individually without loop

1 Ansicht (letzte 30 Tage)
Bob Thompson
Bob Thompson am 14 Apr. 2021
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?

Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Produkte


Version

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by