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

 채택된 답변

Ameer Hamza
Ameer Hamza 2020년 11월 8일
편집: Ameer Hamza 2020년 11월 8일

0 개 추천

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

leyla ahmed
leyla ahmed 2020년 11월 8일
It worked!! Thank you , Ameer
Ameer Hamza
Ameer Hamza 2020년 11월 8일
I am glad to be of help!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 MATLAB Coder에 대해 자세히 알아보기

질문:

2020년 11월 8일

댓글:

2020년 11월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by