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!