matrix operations within an array

Hi, I am not an advanced matlab user and I would appreciate any help wit my code.
The basic idea is to create an array of of matrices and then manipulate or transform the
matrices in the array, for example, let us start with something simple like transpose
each matrix matrix of the array. I am using arrayfun and transpose to do that.
I would appreciate any code input or any reference for advanced tutorial on how to manipulate
or apply functions to elements of an array. Thanks.
Here is my code, but it does not work.
>> X=2*rand(2,3,10)-1; % array of length N of 2 by 2 random matrices
Y=arrayfun(@(x) x',X );
% checking
X(:,:,1) % first matrix of the array X
Y(:,:,1) % first matrix of the array Y, X was not tranposed
ans =
-0.2198 0.2390 0.5588
-0.5573 0.1354 -0.9212
ans =
-0.2198 0.2390 0.5588
-0.5573 0.1354 -0.9212
>>

回答 (1 件)

Andrei Bobrov
Andrei Bobrov 2014 年 3 月 20 日
編集済み: Andrei Bobrov 2014 年 3 月 20 日

0 投票

permute(X,[2 1 3]) % transposed each frame
variant with arrayfun (badly)
Y = arrayfun(@(ii)X(:,:,ii)',1:size(X,3),'un',0 );
Y = cat(3,Y{:});

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

質問済み:

2014 年 3 月 20 日

編集済み:

2014 年 3 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by