I have pairs of A{i}=[ai bi]. How can I change them to pairs B{i}=[bi ai]. I like to use Matlab special features in matrices.

 채택된 답변

Jos (10584)
Jos (10584) 2014년 1월 23일

0 개 추천

% the data
A = {[1 2], [3 4] , [5 6]}
% the insight
help fliplr
help cellfun
% the engine
B = cellfun(@fliplr, A, 'un', 0)

추가 답변 (1개)

Walter Roberson
Walter Roberson 2014년 1월 23일

0 개 추천

B = mat2cell( fliplr(cell2mat(A)), ones(length(A)), length(A{1});

댓글 수: 1

Ayob
Ayob 2014년 1월 23일
편집: Ayob 2014년 1월 23일
I check it,but it didn't work.
A{1}=[1 2]
A{2}=[3 4]
A{3}=[5 6]
B=mat2cell(fliplr(cell2mat(A)), ones(length(A)), length(A{1}))
*bold*
_??? Error using ==> mat2cell at 105
Input arguments, D1 through D2, should be vectors._

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

질문:

2014년 1월 23일

답변:

2014년 1월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by