Drexel dragonThe Math ForumDonate to the Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: sum all elements of a cell array
Replies: 19   Last Post: Apr 25, 2012 6:10 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Matt J

Posts: 4,996
Registered: 11/28/09
Re: sum all elements of a cell array
Posted: Apr 24, 2012 10:46 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

This might just add to the confusion, but here's a totally different way




which uses the following utility

function Graph=interdists(A,B)
%Finds the graph of distances between point coordinates
% (1) Graph=interdists(A,B)
% in:
% A: matrix whose columns are coordinates of points, for example
% [[x1;y1;z1], [x2;y2;z2] ,..., [xM;yM;zM]]
% but the columns may be points in a space of any dimension, not just 3D.
% B: A second matrix whose columns are coordinates of points in the same
% Euclidean space. Default B=A.
% out:
% Graph: The MxN matrix of separation distances in l2 norm between the coordinates.
% Namely, Graph(i,j) will be the distance between A(:,i) and B(:,j).
% (2) interdists(A,'noself') is the same as interdists(A), except the output
% diagonals will be NaN instead of zero. Hence, for example, operations
% like min(interdists(A,'noself')) will ignore self-distances.
% See also getgraph

if nargin<2
elseif ischar(B)&&strcmpi(B,'noself')


Graph=l2norm(bsxfun(@minus, A, B),1);


if noself

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum 1994-2015. All Rights Reserved.