Evaluating exp(x) * sin(x): What's the Problem?

  • Thread starter Thread starter waht
  • Start date Start date
AI Thread Summary
The discussion revolves around an error encountered when trying to evaluate the expression exp(x) * sin(x) for a list generated as x = (-10:0.1:10). The error message indicates a problem with nonconformant arguments due to the use of the standard multiplication operator (*), which does not support element-wise operations for matrices. The solution provided is to use the element-wise multiplication operator (.*), which allows for proper evaluation of the expression, resulting in a 1 x 101 matrix. This highlights the importance of using the correct operators for matrix operations in programming environments.
waht
Messages
1,499
Reaction score
4
When I generate a list x = (-10:0.1:10)

and want to evaluate it using a function

exp(x) * sin(x)

I get this error

error: operator *: nonconformant arguments (op1 is 1x101, op2 is 1x101)
error: evaluating binary operator `*' near line 4, column 11
error: evaluating assignment expression near line 4, column 3

wondering what's the problem here?
 
Physics news on Phys.org
try exp(x).*sin(x) which is a matrix element by element multiply which should give you a 1 x 101 matrix.
 
Thanks in worked. Didn't know you had to use .* operator.
 

Similar threads

Replies
2
Views
5K
Replies
4
Views
2K
Replies
4
Views
2K
Replies
6
Views
2K
Replies
1
Views
3K
Replies
1
Views
2K
Replies
1
Views
10K
Replies
4
Views
8K
Back
Top