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
2014년 3월 20일
편집: Andrei Bobrov
2014년 3월 20일
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 Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!