Multiplications of functions in Matlab

In summary, the syntax for multiplying two functions in Matlab is to use the asterisk (*) operator between the two functions. You can also multiply more than two functions by using the asterisk operator between each function. Matrices can also be multiplied in Matlab using the dot (.) operator for element-wise multiplication. The order in which functions are multiplied matters in Matlab, and it follows the standard mathematical order of operations. It is also possible to multiply functions of different dimensions in Matlab, with the resulting function's dimensions depending on the original functions.
  • #1
mech-eng
828
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
  • #2
You need to use .* to perform element-wise multiplication on each element of these vectors.
 

FAQ: Multiplications of functions in Matlab

What is the syntax for multiplying two functions in Matlab?

The syntax for multiplying two functions in Matlab is to use the asterisk (*) operator between the two functions. For example, if you have two functions f(x) and g(x), the multiplication would be written as f(x)*g(x).

Can I multiply more than two functions in Matlab?

Yes, you can multiply as many functions as you need in Matlab. Simply use the asterisk operator between each function, such as f(x)*g(x)*h(x).

How do I handle matrices when multiplying functions in Matlab?

In Matlab, you can use the dot (.) operator to perform element-wise multiplication on matrices. This means that each element in the first matrix will be multiplied by its corresponding element in the second matrix. For example, A = [1 2; 3 4] and B = [5 6; 7 8], then A.*B will result in [5 12; 21 32].

Is there a specific order in which I should multiply functions in Matlab?

Yes, the order in which you multiply functions in Matlab matters. Matlab follows the standard mathematical order of operations, where multiplication is performed before addition and subtraction. It is important to use parentheses when necessary to ensure the correct order of operations is followed.

Can I multiply functions of different dimensions in Matlab?

Yes, you can multiply functions of different dimensions in Matlab. However, the dimensions of the resulting function will depend on the dimensions of the original functions. For example, if you multiply a 2x3 matrix with a 3x4 matrix, the resulting function will be a 2x4 matrix.

Similar threads

Replies
4
Views
3K
Replies
8
Views
845
Replies
5
Views
1K
Replies
5
Views
2K
Replies
1
Views
2K
Replies
11
Views
3K
Replies
5
Views
2K
Replies
4
Views
1K
Replies
5
Views
2K
Replies
2
Views
2K
Back
Top