I am receiving a "parse error" in this function. Can anyone help me?

function y = f2(x)
y = x.^7 -6.0*x.^6 -14.1*x.^5 +97.6*x.^4 +70.5*x.^3 -423.9*x.^2 -169.0*x. +443.9 ;
end
I got the error on the last "+"
Thank you any help will be appreciated

 채택된 답변

Rik
Rik 2020년 5월 1일

1 개 추천

You have a dot before the plus. Addition is always an element-wise operation, so you don't need a dot there.

댓글 수: 2

Alternately, since you're trying to evaluate a polynomial, consider using the polyval function.
Thank you both very much for your responses. You were right the dot before the plus was the issue.

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

추가 답변 (0개)

카테고리

제품

릴리스

R2019b

태그

Community Treasure Hunt

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

Start Hunting!

Translated by