Shift sheets of matrix individually without loop

1 visualización (últimos 30 días)
Bob Thompson
Bob Thompson el 14 de Abr. de 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?

Respuestas (0)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Productos


Versión

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by