Cross-sum operation in matlab -


is there efficient way cross-sum operation in matlab. given 2 sets , b, cross-sum pairwise addition of vectors , b?

yes:

a=[1 2 3 4] b=[50 60 70 ] bsxfun(@plus, , b') 

in gnu octave or matlab 2016b can write:

a+b' 

if elements of set vectors possible solution:

a=[1 2 3;4 5 6] b=[10 20 30; 40 50 60;70 80 90] [a, b]= meshgrid(1:size(a,1), 1:size(b,1)) a(a,:) + b(b,:) 

or

a={[1 2 3], [4 5 6]} b= {[10 20 30],[40 50 60],[70 80 90]} [a,b]=meshgrid(1:length(a),1:length(b)) cell2mat(a(a))+ cell2mat(b(b)) 

Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -