Multiplications of functions in Matlab

  • Context: MATLAB 
  • Thread starter Thread starter mech-eng
  • Start date Start date
  • Tags Tags
    Functions Matlab
Click For Summary
SUMMARY

The discussion centers on the error encountered in MATLAB when attempting to multiply two functions, specifically using the expression `f=exp(-t)*sin(t)`. The error message "Inner matrix dimensions must agree" indicates that standard matrix multiplication is being incorrectly applied. To resolve this, users must utilize the element-wise multiplication operator `.*` instead, allowing for the correct computation of `f=exp(-t).*sin(t)`. This adjustment also enables successful plotting of the resulting graph using the `plot(x,y)` function.

PREREQUISITES
  • Familiarity with MATLAB syntax and operations
  • Understanding of element-wise versus matrix operations in MATLAB
  • Basic knowledge of plotting functions in MATLAB
  • Experience with mathematical functions such as exponential and sine
NEXT STEPS
  • Research the use of element-wise operations in MATLAB, focusing on operators like `.*`, `./`, and `.^`
  • Explore MATLAB's plotting functions, particularly `plot`, `xlabel`, and `ylabel` for graph customization
  • Learn about MATLAB's error handling and debugging techniques to troubleshoot similar issues
  • Investigate advanced mathematical functions in MATLAB for more complex operations
USEFUL FOR

This discussion is beneficial for MATLAB users, particularly students and engineers working with mathematical modeling and data visualization, as well as anyone looking to enhance their understanding of matrix and element-wise operations in MATLAB.

mech-eng
Messages
826
Reaction score
13
Hi. When I try to this multiplication: t=[0:0.02:1]; f=exp(-t)*sin(t)
Error using *
Inner matrix dimensions must agree.

in Matlab I take the error above and I can not also plot its graph by plot(x,y). Can somebody help me?
 
Physics news on Phys.org
You need to use .* to perform element-wise multiplication on each element of these vectors.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
5K