MATLAB: I want to divide each row of a matrix with corresponding element in another matrix .Please help. matrix For eg: I have a matrix A=[9 6 3; 4 2 8; 1 0 0;] divide A by B=[3 2 1] to get the result C=[3 2 1; 2 1 4; 1 0 0;] Best Answer Use bsxfun:>> A = [9,6,3;4,2,8;1,0,0];>> B = [3,2,1];>> bsxfun(@rdivide,A,B(:))ans = 3 2 1 2 1 4 1 0 0 Related SolutionsMATLAB: Cumnwise multiplication between a matrix and a vector. A = [1 2 3; 7 2 4; 2 0 4]B = [1 2 3]C = bsxfun(@times,A,B) MATLAB: Scatter3, Meshgrid coordinate misalignment. How to fix this Use NDGRID instead of MESHGRID. Related QuestionSimpler code for aggregating data by sumHi, I want to divide a matrix in 2 parts verticallyChoose row cell of matrixHow to multiply each row of a matrix with every row of another matrix elementwiseBelow is the probabilistic neural network for classification, but it is not working fine. Can someone help to improve it? especially how to recalculate training, validation and test performance.
Best Answer