W = bsxfun(@times,V,M) If V is a row vector you will get V element-wise times each row of M. Similarly if V is a column vector. Answer from James Tursa on mathworks.com
🌐
MathWorks
mathworks.com › matlab › mathematics › elementary math › arithmetic operations
times - Multiplication - MATLAB
This MATLAB function multiplies arrays A and B by multiplying corresponding elements.
Discussions

When do I need element wise operators?
If you use the normal * operator, Matlab assumes you want to do a traditional matrix multiplication, where you take the inner products of the rows of one matrix against the columns of another. Therefore, if you multiply two vectors together using *, Matlab will report an error. For division (/), there is no "matrix division" that is defined, so any time you divide two vectors or matrices, they must be the same size, and you must use ./ . In your problem, the operations in the denominator result in a vector of results. There is no way to divide over a whole vector, but what you want is to divide over each element of the vector. None of this matters for scalars though. In your problem, mu is a scalar, so you can multiply mu by a vector or matrix using just * with no problems. You could write .* in your problem, and still get the same answer with no errors, but it would not be the correct code. More on reddit.com
🌐 r/matlab
6
4
January 21, 2019
I Want to perform element wise matrix multiplication
I Want to perform element wise matrix... Learn more about matrix More on mathworks.com
🌐 mathworks.com
2
0
June 12, 2017
Element wise multiplication by a vector
Element wise multiplication by a vector. Learn more about matrix manipulation More on mathworks.com
🌐 mathworks.com
3
1
March 7, 2013
performance - Fastest way to do repeated element wise matrix multiplication in MATLAB? - Stack Overflow
1 Parallel code is taking longer time than sequential code using Parallel computing toolbox in MATLAB. Why? 186 How to get element-wise matrix multiplication (Hadamard product) in numpy? More on stackoverflow.com
🌐 stackoverflow.com
🌐
MathWorks
mathworks.com › symbolic math toolbox › symbolic computations in matlab › operators and elementary operations
times - Symbolic array multiplication - MATLAB
Multiply the matrices by using the element-wise multiplication operator .*. This operator multiplies each element of the first matrix by the corresponding element of the second matrix.
🌐
MathWorks
mathworks.com › matlab › mathematics › elementary math › arithmetic operations
Array vs. Matrix Operations - MATLAB & Simulink
If one operand is a scalar and the other is not, then MATLAB implicitly expands the scalar to be the same size as the other operand. For example, you can compute the element-wise product of a scalar and a matrix.
🌐
MathWorks
mathworks.com › simulink › simulink environment fundamentals › block libraries › math operations
Product, Matrix Multiply - Multiply and divide scalars and nonscalars or multiply and invert matrices - Simulink
When you set Multiplication to Element-wise(.*), the Product block is in Element-wise mode, in which it operates on the individual numeric elements of any nonscalar inputs. The MATLAB® equivalent is the .* operator.
🌐
Reddit
reddit.com › r/matlab › when do i need element wise operators?
r/matlab on Reddit: When do I need element wise operators?
January 21, 2019 -

Hi guys,

I am trying to implement this function in Matlab: https://imgur.com/a/iM3PepF.

The solution I've been provided with by my teacher is the following: https://imgur.com/a/iM3PepF.

X and Y are vectors.

My question now is: Why do I need for the first operator an element wise operator (.*) but not also for the second and third operator? This is really confusing me.

Thanks for your help!

Find elsewhere
🌐
MathWorks
mathworks.com › matlabcentral › answers › 344326-i-want-to-perform-element-wise-matrix-multiplication
I Want to perform element wise matrix multiplication - MATLAB Answers - MATLAB Central
June 12, 2017 - You see you can multiply only same classes. Class of a is uint8, so you need to convert b into the same class. ... https://www.mathworks.com/matlabcentral/answers/344326-i-want-to-perform-element-wise-matrix-multiplication#comment_460933
🌐
MathWorks
mathworks.com › matlabcentral › answers › 2173842-elementwise-multiplication-of-two-3d-matrices
Elementwise multiplication of two 3D matrices - MATLAB Answers - MATLAB Central
February 10, 2025 - To multiply two 3D matrices element-wise in MATLAB, the appropriate operator is the dot multiplication operator `.*`, not `pagemtimes`. The `pagemtimes` function is designed for matrix multiplication, which requires that the inner dimensions ...
🌐
ScienceDirect
sciencedirect.com › topics › engineering › element-multiplication
Element Multiplication - an overview | ScienceDirect Topics
Write MATLAB commands that compute the value of the vector r as shown below. ... We now discuss several different ways to multiply arrays. You can multiply any vector or matrix by a scalar number. Mathcad multiplies each element in the array by the scalar and returns the results.
🌐
Usc
viterbik12.usc.edu › wp-content › uploads › 2017 › 06 › AliMarjani-MATLAB-Tutorial-Second-Season-2017.pdf pdf
A. Matrix-wise and element-wise operations
... A.1. Element-wise operations · If we want the operator to operate element-wise (the operator · will work on each one of the elements from the first matrix · and its corresponding element on the other matrix), we should · just put a dot (“.”) in front of the operator.
🌐
MathWorks
mathworks.com › matlabcentral › answers › 1912765-multiply-individual-cells-of-a-matrix-by-a-scalar-using-a-for-loop
Multiply Individual Cells of a Matrix by a Scalar Using a For Loop - MATLAB Answers - MATLAB Central
February 15, 2023 - https://www.mathworks.com/matlabcentral/answers/1912765-multiply-individual-cells-of-a-matrix-by-a-scalar-using-a-for-loop#answer_1171875 ... You can use the .* operator to perform element-wise multiplication between a matrix and a scalar.
Top answer
1 of 1
1
There are several ways to multiply each column of a matrix by the corresponding element of the vector. The first is to use the REPMAT function to expand the vector to the same size as the matrix and them perform elementwise multiplication using .* -- however, this will require a large amount of memory. For example: To multiply each column of vector b with the row a: a = [1 2 3]'; b = [1 2; 3 4; 5 6]; x = repmat(a,1,size(b,2)); x.*b % or dot(x,b) If the matrix involved is a square matrix then the vector can be converted to a diagonal matrix and then multiplied as follows: Amat = rand(3,3); b = rand(1,3); c = Amat*diag(b); %or %c = Amat*diag(1./Bvec); The second method is to use a FOR loop. For long vectors prior to MATLAB 6.5 (R13), this may take a significant amount of time; however, making use of the acceleration technology introduced in MATLAB 6.5 (R13), this time is drastically reduced. If you're using MATLAB 6.5 (R13), copy the following code into a function file for an example that does this: function B=DivideColumns(N) % Avoiding creating too large a matrix if nargin<1 || N >2500 N = 500; end tic A = 1./hilb(N); c = 1:N; B = A; % So that we don't overwrite A T1 = toc; tic for i=1:N B(:,i) = B(:,i)/c(i); end T2 = toc; S1 = sprintf('Constructing the %d by %d ... A matrix took %f seconds.', N, N, T1); S2 = sprintf('\nDividing the columns of A ... by elements of c took %f seconds', T2); disp([S1 S2]) For large values of N, you can see that generating A will take much more time than performing the division. Another option is to use a diagonal or sparse diagonal matrix form of your vector. For example, the following code will produce a B that agrees with the B returned by the code above: function B = TimesDiag(N) % Avoiding creating too large a matrix if nargin<1 || N >2500 N = 500; end tic A = 1./hilb(N); c = 1:N; T1 = toc; tic % Replace this with "B = A*spdiag(c(:),0,N,N);" % if N is very large: B = A*diag(c); T2 = toc; S1 = sprintf('Constructing the %d by %d ... A matrix took %f seconds.', N, N, T1); S2 = sprintf('\nDividing the columns of ... A by elements of c took %f seconds', T2); disp([S1 S2])
🌐
MathWorks
mathworks.com › matlabcentral › answers › 1445384-what-s-an-efficient-way-to-do-an-element-wise-multiplication-of-matrices-with-different-sizes-withou
What's an efficient way to do an element-wise multiplication of matrices with different sizes without a permutation or fo... - MATLAB Answers - MATLAB Central
September 2, 2021 - I would like to do an element wise multiplication of each column of B by each column of A. That would be done 181 times for each column in B. The code below accomplishes that by replicating matrix B so that it has dimensions of 255x10x181 and then permutes it to have final dimensions of 255x181x10 and then that matrix is multiplied by A. Matlab automatically takes care of replicating matrix A to account for the third dimension.
🌐
MathWorks
mathworks.com › matlabcentral › answers › 415735-element-wise-product-in-simulink
Element-wise product in Simulink - MATLAB Answers - MATLAB Central
August 22, 2018 - https://www.mathworks.com/matlabcentral/answers/415735-element-wise-product-in-simulink#comment_602194 ... For element-wise multiplication (Hadamard product) in Matlab using ".*", both matrix dimesions must be same.
🌐
MathWorks
mathworks.com › matlabcentral › answers › 66780-multiply-each-element-of-structured-array-assignment-of-structured-array
multiply each element of structured array, assignment of structured array - MATLAB Answers - MATLAB Central
March 11, 2013 - I have two questions: 1. I want to multiply each element of the structured array so that A.B*2 would equal 10,12,14 instead of 5,6,7. but instead I get the error ... Too many input arguments. 2. How do I make a copy of the structured array? I have tried but it just results in the first element. ... Sign in to comment. Sign in to answer this question. ... https://www.mathworks.com/matlabcentral/answers/66780-multiply-each-element-of-structured-array-assignment-of-structured-array#answer_78237