I am a beginner in MATLAB, and I need to represent e(-t2).
I know that, for example, to represent ex I use exp(x)
, and I have tried the following
1) tp=t^2; / tp=t*t; x=exp(-tp);
2) x=exp(-t^2);
3) x=exp(-(t*t));
4) x=exp(-t)*exp(-t);
What is the correct way to do it?
If t
is a matrix, you need to use the element-wise multiplication or exponentiation. Note the dot.
x = exp( -t.^2 )
or
x = exp( -t.*t )