How to write down functions

14 visualizaciones (últimos 30 días)
leyla ahmed
leyla ahmed el 8 de Nov. de 2020
Comentada: Ameer Hamza el 8 de Nov. de 2020
How do i write xe^x^2-10^6 and 2x^2 e^x^2+e^x^2 on matlab? I can't figure it out. Matlab says it's an invalid expression

Respuesta aceptada

Ameer Hamza
Ameer Hamza el 8 de Nov. de 2020
Editada: Ameer Hamza el 8 de Nov. de 2020
You need to specify the multiplication operator in MATLAB explicitly. Also, 'e' is not defined as a constant in MATLAB
y1 = x*exp(x^2)-10^6
y2 = 2*x^2*exp(x^2)+exp(x^2)
If 'x' is a vector then use element-wise operators
y1 = x.*exp(x.^2)-10^6
y2 = 2*x.^2.*exp(x.^2)+exp(x.^2)
Completing this free course: https://www.mathworks.com/learn/tutorials/matlab-onramp.html will help understand the basics of MATLAB.
  2 comentarios
leyla ahmed
leyla ahmed el 8 de Nov. de 2020
It worked!! Thank you , Ameer
Ameer Hamza
Ameer Hamza el 8 de Nov. de 2020
I am glad to be of help!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre MATLAB Coder en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by