フィルターのクリア

How can I change pairs?

7 ビュー (過去 30 日間)
Ayob
Ayob 2014 年 1 月 23 日
回答済み: Jos (10584) 2014 年 1 月 23 日
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 日
% 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 日
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._

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

カテゴリ

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