How to write down functions
14 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
Ameer Hamza
2020-11-8
编辑:Ameer Hamza
2020-11-8
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.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!