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 Center および File ExchangeLoops 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