フィルターのクリア

Is it possible to rotate the data inside each cell of a cell array

2 ビュー (過去 30 日間)
Aaron Smith
Aaron Smith 2017 年 7 月 5 日
コメント済み: Ijaz Ahmad 2021 年 11 月 24 日
I have a cell array containing a matrix inside of each cell. I need to rotate the matrices. I have already found the rot90 command which works fine for the individual matrix oor for rotating the cells of a cell array. My query is, is it possible to rotate each of the matrices without doing it individually?
I was looking at using cellfun to attempt to do this
cellfun(rot90(finishCell{k}, 3));
This appears to manipulate the cells of the cell array and not the data inside

採用された回答

Jan
Jan 2017 年 7 月 5 日
While
C = cellfun(@rot90,C,'uni',0)
creates a copy of C, such that the double size of memory is required temporarily, a loop creates the duplicates one after the other:
for iC = 1:numel(C)
C{iC} = rot90(C{iC});
end
This might avoid the memory problems.
  3 件のコメント
Valentino Cristini
Valentino Cristini 2021 年 9 月 22 日
Hi, how would you add the k factor (how many times it shoud rotate the array by 90 degrees)?
Ijaz Ahmad
Ijaz Ahmad 2021 年 11 月 24 日
k = randi([0,3], [1,numel(C)]);
for iC = 1:numel(C)
C{iC} = rot90(C{iC}, k(iC));
end

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by