MATLAB: Distance between all elements of row vector distance So, I have 1×200 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 200×200/2 values. Best Answer Hint:%%row = rand(1,6);cell2mat( reshape( arrayfun( @(jj) row(jj)-row, (1:6), 'uni', false ), [],1 ) )outputsans = 0 -0.0790 -0.0644 0.2865 0.0233 0.5075 0.0790 0 0.0146 0.3655 0.1023 0.5866 0.0644 -0.0146 0 0.3509 0.0877 0.5719 -0.2865 -0.3655 -0.3509 0 -0.2633 0.2210 -0.0233 -0.1023 -0.0877 0.2633 0 0.4843 -0.5075 -0.5866 -0.5719 -0.2210 -0.4843 0 Related SolutionsMATLAB: Delete rows and columns with zeros in a multi level cell array matrix. fun = @(in)in(~cellfun(@(x)[strcmp(x,'0')||isempty(x)] , in));result = cellfun(fun, datafi2 , 'UniformOutput', false); MATLAB: “permat” and more efficient coding for k = 1 : length(listl) lol{k} = cellstr( num2str( ixsL(:), [listl{k} '%u'] );end Related QuestionRemove empty rows from matrixServeral normrnd without a loopHow many times does each combination of numbers appearMultiplying 2 matrices with difference sizesHow to extract data from strctureError vertcat not using vertcatReshape a matrix in different way
Best Answer