Solving MatLab Misunderstanding: Element-by-Element and Point-wise

  • Context: MATLAB 
  • Thread starter Thread starter steve2510
  • Start date Start date
  • Tags Tags
    Matlab
Click For Summary
SUMMARY

The discussion clarifies the use of the period operator (.) in MATLAB, specifically its role in element-by-element operations versus traditional matrix multiplication. The dot operator (.*) is essential for performing element-wise multiplication on arrays of the same dimensions, while omitting the dot operator indicates standard matrix multiplication. For instance, the expression y = sqrt(t).*sin(2t); performs element-wise operations, while y = sqrt(t)*sin(2t); does not. Understanding this distinction is crucial for effective MATLAB programming, especially in engineering applications.

PREREQUISITES
  • Basic understanding of MATLAB syntax and operations
  • Familiarity with vectors and matrices in MATLAB
  • Knowledge of element-wise versus matrix operations
  • Concept of array dimensions and compatibility in MATLAB
NEXT STEPS
  • Study MATLAB's element-wise operations, focusing on operators like .* and ./
  • Learn about matrix multiplication and its rules in MATLAB
  • Explore MATLAB's array manipulation functions for advanced data handling
  • Practice with MATLAB's built-in functions to reinforce understanding of arrays and matrices
USEFUL FOR

This discussion is beneficial for engineering students, MATLAB users, and anyone looking to deepen their understanding of array operations and matrix mathematics in MATLAB.

steve2510
Messages
35
Reaction score
0
I'm current learning MatLab before i start my second year of engineering and i don't really understand a fundamental aspect of it. My problem is the use of the period "." and when it is deemed to be necessary.

I've looked up what this operator does and found definitions such as Element by element, Point-wise, ect. My problem is these don't mean much to me, I've done work on vectors and matrices, however matrices work consisted of mostly doing practice problems so maybe i don't full understand the fundamentals of matrices. Is there anyway somebody could explain to me what the period operator actually does.

For example why are these two different
y = sqrt(t).*sin(2t);
y = sqrt(t)*sin(2t);

And
y=(3.^x)./(1+3.^x)
y=(3^x )/ (1+3^x)

Any clarification would be much appreciated, thank you.

P.S I hope this is in the right board
 
Physics news on Phys.org
Dot multiplication .* is used to perform element-by-element array multiplication. An array is either a single row (row vector) or single column (column vector) of some values. For array-array multiplication to work, the arrays must be the same length.

Suppose, you have an array A=[3; 2; 5] which is a 3x1 array and want to multiply it by B=[6; 9; 2] which is another 3x1 array (same lengths), you tell MATLAB to do the following;
Ans=A.*B which multiplies the 2 arrays on an element-by-element basis. This means it multiplies 3x6, 2x9 and 5x2 giving a resultant arry of [18; 18; 10]

Leaving out the dot operator is for matrix multiplication which is differenet.
The 2 examples you provided don't really help to explain the purpose of the dot operator as they are just scalar x scalar examples.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
2
Views
3K
  • · Replies 10 ·
Replies
10
Views
4K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 9 ·
Replies
9
Views
5K