matlab,min,matrix-multiplication,bsxfun

I believe you need this correction in your code - [minindex_alongL2, minindex_alongL1] = ind2sub([size(L2,1) size(L1,1)],p) For the solution, you need to add the size of p into the index finding in the last step as the vector whose min is calculated has the "added influence" of alpha - [minindex_alongL2, minindex_alongL1,minindex_alongalpha]...

Since matx is a 3D array and f is a row vector of length equal to the number of elements in dim-3 of matx, you can perform the bsxfun equivalent expansion/replication with repmat and then perform elementwise division like so - % Get size of matx [m1,n1,r1] = size(matx); %//...

image,matlab,matrix,transpose,bsxfun

The problem here is that your function doesn't return an output the same shape as the input it is given. Although the requirement for bsxfun is that the function operates element-wise, it is not called with scalar elements. So, you need to do this: x = randi(5, 4, 5) [m,...

python,matlab,numpy,octave,bsxfun

bsxfun in Matlab stand for binary singleton expansion, in numpy it's called broadcasting and should happen automatically. The solution will depend on the dimensions of your X, i.e. is it a row or column vector but this answer shows one way to do it: How to multiply numpy 2D array...

performance,matlab,vectorization,bsxfun

Acording to the documentation, when you call bsxfun with an arbitrary function func, funcmust be able to accept as input either two column vectors of the same size, or one column vector and one scalar, and return as output a column vector of the same size as the input(s). Your...

performance,matlab,matrix,matrix-multiplication,bsxfun

Send x to the third dimension, so that singleton expansion would come into effect when bsxfun is used for multiplication with A, extending the product result to the third dimension. Then, perform the bsxfun multiplication - val = bsxfun(@times,A,permute(x,[3 1 2])) Now, val is a 3D matrix and the desired...

In general, you would need to use bsxfun several times, because each bsxfun can only carry out one operation. But in this case it can be done just with matrix multiplication and element-wise multiplication: delta_g = ((1-z).*(W*delta)).'; ...

arrays,performance,matlab,vectorization,bsxfun

You need to use bsxfun to extend your case to a vector case. Code dxcp = [1 2 3 6 10 20]; X = [2 5 9 18] abs_diff_vals = abs(bsxfun(@minus,dxcp,X')); %%//' [~,k] = min(abs_diff_vals,[],2); X = dxcp(k) Output X = 2 5 9 18 X = 2 6 10...

arrays,performance,matlab,matrix,bsxfun

You just need bsxfun and a little bit of permute: z = bsxfun(@plus, x, permute(y, [3 2 1])); The key is to properly rearrange the dimensions of y so that the singleton expansion performed by bsxfun gives you the desired result....

matlab,neural-network,vectorization,bsxfun

There is a parallelogram-like structure of blocks you are creating inside the nested loops with iLowMax:iHighMax,jLowMax:jHighMax which won't lead to any easy vectorizable codes. But you can go full-throttle vectorization on that if performance is paramount for your case and seems like convolution would be of good use there. Listing...