This is just a minor improvement over Divakar’s answer. It is a little faster because it replaces a 3D-array permute with a 2D-array permute:
B = bsxfun(@times, permute(A, [1 3 2]), permute(A, [3 1 2]));
More Related Contents:
- How can I apply a function to every row/column of a matrix in MATLAB?
- Multiply a 3D matrix with a 2D matrix
- How do I compare all elements of two arrays?
- MATLAB: Subtracting matrix subsets by specific rows
- How can I index a MATLAB array returned by a function without first assigning it to a local variable?
- How do you concatenate the rows of a matrix into a vector?
- How do I visualize a matrix with colors and values displayed?
- Use a vector as an index to a matrix
- Create a zero-filled 2D array with ones at positions indexed by a vector
- How can I change the values of multiple points in a matrix?
- Construct adjacency matrix in MATLAB
- Replace specific columns in a matrix with a constant column vector
- How to assign values to a MATLAB matrix on the diagonal?
- Why is reshape so fast? (Spoiler: Copy-on-Write)
- pdist2 equivalent in MATLAB version 7
- How do I resize a matrix in MATLAB?
- Is there a substitute for blockproc in Matlab?
- Matrix “Zigzag” Reordering
- Sorting entire matrix according to one column in matlab
- Building a matrix by merging the same row vector multiple times
- Matlab: repeat every column sequentially n times [duplicate]
- Fast Algorithms for Finding Pairwise Euclidean Distance (Distance Matrix)
- Index of max and min value in an array
- How can I sort a 2-D array in MATLAB with respect to one column?
- General method to find submatrix in matlab matrix
- How to find out if a matrix is singular? [duplicate]
- Extract arbitrarily rotated plane of data from 3D array as 2D array
- How do I double the size of a vector in MATLAB with interpolation?
- How do I convert a 2X2 matrix to 4X4 matrix in MATLAB?
- Display matrix with row and column labels