Distance between all elements of row vector
Ältere Kommentare anzeigen
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.
Akzeptierte Antwort
Weitere Antworten (1)
madhan ravi
am 18 Feb. 2019
Straightforward:
row.'-row
3 Kommentare
Ana
am 18 Feb. 2019
madhan ravi
am 18 Feb. 2019
Did you run the code?
per isakson
am 18 Feb. 2019
Bearbeitet: per isakson
am 18 Feb. 2019
%%
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
Kategorien
Mehr zu Dates and Time finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!