Why doesn't this matlab code work?!

조회 수: 1 (최근 30일)
Aryo Aryanapour
Aryo Aryanapour 2021년 4월 19일
댓글: Aryo Aryanapour 2021년 4월 20일
>> x = -5:1:5;
>> y = exp(x)*(x.^3-5*x.^2+5*x+1);
Error using *
Incorrect dimensions for matrix multiplication. Check that the number of columns in the first matrix
matches the number of rows in the second matrix. To perform elementwise multiplication, use '.*'.
Related documentation
>> plot(x,y)
Unrecognized function or variable 'y'.
thank you

채택된 답변

the cyclist
the cyclist 2021년 4월 20일
You missed a spot where you needed an element-wise operation, multiplying the exp(x) by the other term:
x = -5:1:5;
y = exp(x).*(x.^3-5*x.^2+5*x+1);
  댓글 수: 1
Aryo Aryanapour
Aryo Aryanapour 2021년 4월 20일
Thank you very much
it works now

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by