필터 지우기
필터 지우기

Have I used polyfit/polyval correctly

조회 수: 2 (최근 30일)
jacob Mitch
jacob Mitch 2019년 10월 28일
I am just trying to get used to the polyfit and polyval function.
My question says to use the polyfit and polyval functions to approximate price for N=1 N=5 N=10 and plot the approximation
I have my data file as a 15x5 double with prices being the 5th column day being the first column. I have written.
day = Data(:,1)); %first column of days
price =Data(:,5) ; %data we want to approximate
T = table(day, price); %create a table for easier computation
for i=[1 5 10] %N values
[p,~,mu] = polyfit(T.day, T.price, i);
f = polyval(p,day,[],mu);
plot(day,price) %plot of prices
hold on
plot(day,f) %approximation plot
end
Im just wondering if I am correct in how I have done that. the approximations seem in line with the graph but I cant see were I've approximated price

답변 (0개)

카테고리

Help CenterFile Exchange에서 Financial Toolbox에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by