Lagrange polynomial: two equivalent m-files

I have a problem with the Lagrange polynomial in Matlab.
Here they write
% YY = LAGRANGEPOLY(X,Y,XX) returns the values of the polynomial
% sampled at the points specified in XX -- the same as
% YY = POLYVAL(LAGRANGEPOLY(X,Y)).
%
I understand that XX are the points at which the Lagrange polynomial is evaluated. But the the command after the second YY doesn't contain XX. So why these two YY are the same ? How can they be the same ??

댓글 수: 4

Torsten
Torsten 2022년 12월 23일
편집: Torsten 2022년 12월 23일
Must read:
YY = polyval(lagrangepoly(X,Y),XX)
instead of
YY = polyval(lagrangepoly(X,Y))
But why don't you simply run the code with the example provided ?
Jan
Jan 2022년 12월 23일
편집: Jan 2022년 12월 23일
Sounds good. But I'm getting these errors, neither possibility works:
>> YY = polyval(lagrangepoly([1,2],[3,4]),[1])
Unrecognized function or variable 'lagrangepoly'.
>> YY = polyval(Lagrang([1,2],[3,4]),[1])
Error using Lagrang
Too many output arguments.
Torsten
Torsten 2022년 12월 23일
편집: Torsten 2022년 12월 23일
lagrangepoly.m is saved in your working directory ?
Jan
Jan 2022년 12월 23일
I see. Now it works fine. I'm new to Matlab thus appologizing my confusion.Thank you.

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

답변 (1개)

the cyclist
the cyclist 2022년 12월 23일

0 개 추천

Assuming you are talking about this submission to the FEX, it is not from Mathworks. It is a user-contributed function. I guess you'd need to ask the author what they meant.

카테고리

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

제품

릴리스

R2019b

질문:

Jan
2022년 12월 23일

댓글:

Jan
2022년 12월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by