MATLAB Simple matrix division in Matlab

AI Thread Summary
To divide each element in matrix b by the corresponding element in matrix a, the correct operation is to use element-wise division, which can be achieved with the syntax b ./ a in many programming languages. The user initially attempted b / a, which is incorrect for element-wise operations. After clarification, it was confirmed that using b ./ a will yield the desired result of a new matrix with values [1 2 3 4].
nb89
Messages
37
Reaction score
0
I have 2 matrices a=[1 2 3 4] and b=[1 4 9 16], i want to divide each term in matrix b by the same term in matrix a, in other words i want to end up with a matrix of [1 2 3 4].

Ive tried doing b/a, which clearly is wrong!

Thanks for any help
 
Physics news on Phys.org
Dr Transport said:
b./a yields an element by element divide...

thank you, i knew it was something simple :D
 
Back
Top