Transposing cells

32 vues (au cours des 30 derniers jours)
Syed Abbas
Syed Abbas le 19 Jan 2012
hi, how can I transpose each cell in a cell array?

Réponse acceptée

the cyclist
the cyclist le 19 Jan 2012
Do you mean that each cell in the cell array contains a matrix, and you want to transpose each matrix? If so, then you need the cellfun command:
% Fill the cell array
a{1} = [1 2; 3 4];
a{2} = [5 6; 7 8];
% Display the cell array before the transpose
a{:}
% Do the transpose
a = cellfun(@transpose,a,'UniformOutput',false);
% Display the results
a{:}
  1 commentaire
Syed Abbas
Syed Abbas le 19 Jan 2012
Great! Thanks

Connectez-vous pour commenter.

Plus de réponses (1)

Jan
Jan le 19 Jan 2012
Or by a loop:
a{1} = [1 2; 3 4];
a{2} = [5 6; 7 8];
for i = 1:numel(a)
a{i} = transpose(a{i});
end
  1 commentaire
Syed Abbas
Syed Abbas le 19 Jan 2012
Thanks!

Connectez-vous pour commenter.

Catégories

En savoir plus sur Matrices and Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by