Simple matrix division in Matlab

Click For Summary
SUMMARY

The discussion focuses on performing element-wise division of two matrices in MATLAB. The user attempts to divide matrix b=[1 4 9 16] by matrix a=[1 2 3 4] using the incorrect syntax b/a, which does not yield the desired result. The correct approach is to use the element-wise division operator b./a, which successfully produces the output matrix [1 2 3 4]. This highlights the importance of understanding MATLAB's operator distinctions for matrix operations.

PREREQUISITES
  • Basic understanding of MATLAB syntax and operations
  • Familiarity with matrix manipulation in MATLAB
  • Knowledge of element-wise operations in MATLAB
  • Understanding of matrix dimensions and compatibility
NEXT STEPS
  • Explore MATLAB's element-wise operators, including .*, .^, and ./
  • Learn about matrix dimensions and broadcasting in MATLAB
  • Investigate MATLAB's built-in functions for matrix operations
  • Review examples of common matrix manipulations in MATLAB documentation
USEFUL FOR

MATLAB users, data analysts, and engineers who need to perform matrix operations and seek to enhance their understanding of element-wise calculations in MATLAB.

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
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 32 ·
2
Replies
32
Views
4K
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
1K
Replies
7
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 9 ·
Replies
9
Views
5K