Help with function/script polynom

I'm supposed to make 3 different codes on how to getCoefficient, getplot and getPolynom in matlab. The first line in the getCoeff code is:
function [coeff] = getCoeff(Xp,Yp)
and I know if I've done it right all I should be able to type in
Xp=[1,4,5,6];
Yp=[5,14,21,70];
coeff=getCoeff(Xp,Yp)
it shouldnt matter what degree the polynom is in, the general look is: p(x)= an*x.^n + an-1*x.^n-1+...+a2*x.^2+a1x+a0
how do I put this in a function?

댓글 수: 3

John D'Errico
John D'Errico 2014년 9월 2일
Do you know what polyfit is?
Sverre
Sverre 2014년 9월 4일
I typed in:
>> Xp = [1,4,5,6];
>> Yp = [5,14,21,70];
>> p = polyfit(Xp,Yp)
Error using polyfit (line 59) Not enough input arguments.
Don't know why it won't work, I'm new to matlab.. all help is appreciated
Sverre
Sverre 2014년 9월 4일
ok I think I figured it out, isntead of typing in
p = polyfit(Xp,Yp)
I typed in:
p = polyfit(Xp,Yp,3)
so I could get the degree the polynom is in.

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

답변 (0개)

카테고리

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

질문:

2014년 9월 2일

댓글:

2014년 9월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by