- What is "e" in e^[(-ax)]^2?
- "ax" is not the same as a * x.
- y6(x) will not work in general, if x is not an integer > 0.
Why y6(x)=e^[(-ax)]^2 didin't work
1 view (last 30 days)
Show older comments

I want to calculate it, but it doesn't work :/
y6(x)=e^[(-ax)]^2
0 Comments
Answers (2)
Jan
on 11 Nov 2021
Edited: Jan
on 11 Nov 2021
Welcome to Matlab!
"It doesn't work" is not a useful description of the occuring problem. Post the error message instead or explain the difference between the result and you expectations.
I see 3 problems:
I guess:
y = exp(-a * x.^2)
These are programming fundamentals in Matlab. Please read the Getting Started chapters and look at Matlab's Onramp. This is more efficient to ask for the basics in the forum.
0 Comments
Walter Roberson
on 11 Nov 2021
- MATLAB has absolutely no implied multiplication, not anywhere. If you want to multiply a and x then you need to put a multiplication operator between the two names. For this purpose, the multiplication operator to use use .* (period followed by asterisk), such as a.*x
- The equation asks you to take the square of x, not the square of (-ax) .
- For this purpose you will probably need to use the .^ operator instead of the ^ operator
- In MATLAB, [] is only used to build lists, such as [1, 1, 2, 3, 5, 8] . You should use () for prioritization.
- In MATLAB,
is written as
. You will find that to be quite common across different programming languages - Having the (x) on the left side is not going to work if x is numeric, and you should instead be creating anonymous functions in such a case, such as y = @(x) sin(x.^2-1) . It is valid to have y(x) on the left hand side if x has been defined as a symbolic variable
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!