Shift sheets of matrix individually without loop

조회 수: 1 (최근 30일)
Bob Thompson
Bob Thompson 2021년 4월 14일
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개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품


릴리스

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by