Distance between all elements of row vector
古いコメントを表示
So, I have 1x200 matrix, (row vector). I want to find difference (x(0)-x(1), x(0)-x(2)...) between all elements of an array. How do I do that ?
I should be having 200x200/2 values.
採用された回答
その他の回答 (1 件)
madhan ravi
2019 年 2 月 18 日
Straightforward:
row.'-row
3 件のコメント
Ana
2019 年 2 月 18 日
madhan ravi
2019 年 2 月 18 日
Did you run the code?
per isakson
2019 年 2 月 18 日
編集済み: per isakson
2019 年 2 月 18 日
%%
row = rand(1,6);
c1 = cell2mat( reshape( arrayfun( @(jj) row(jj)-row, (1:6), 'uni', false ), [],1 ) );
%%
c2 = reshape(row,[],1) - row; % The name, reshape, communicates the intent
>> c2-c1
ans =
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
カテゴリ
ヘルプ センター および File Exchange で Dates and Time についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!