How to determine the polynomial that provides the best fit to this data and use it to predict the thermal efficiency?
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
채택된 답변
The best fit will be a 9th order polynomial - it will go through each point exactly. However it will be badly behaved because in between the points it will go haywire so the estimates will be worthless. So, like Wayne said, you need to decide on an order. As the orders get higher, the fit will get better, but the worse the oscillations in between your training points will be. Once you know that, just do
coefficients = polyfit(x, y, theOrder); % x is the year.
x = 2000;
estimatedY = polyval(coefficients, x);
댓글 수: 11
could you write the code for me? is difficult to write the right code, I see a lot of orange marks under the code :(
No, because it's your homework assignment. Anyway, it's all practically written already. All you have do is assign the years to the x array, and the efficiency to the y array, and call my code. Two more lines and you're done. I can't give you those two lines without doing 100% of the assignment for you. You can post your code if you need help with orange or red lines.
Djati Waluyo
2013년 5월 20일
편집: Djati Waluyo
2013년 5월 20일
Thanks, I would be proud if I had a lecturer like you :)
coefficients = polyfit(x, y, theOrder); % x is the year. what is "theOrder" means?
the Order means the maximum power of the coefficients, the degree of the polynomial
Try an integer between 2 and 9 and see how it goes. See which number looks like a fairly smooth regression and how looks by plotting it like this:
plot(x,y, 'bo', 'LineWidth', 2, 'MarkerSize', 8);
[coefficients, S, mu] = polyfit(x, y, theOrder); % x is the year.
x = 1700:2050;
estimatedY = polyval(coefficients, x, S, mu);
hold on;
plot(x, estimatedY, 'r-', 'LineWidth', 2);
grid on;
yl = ylim;
line([2000 2000], [yl(1), yl(2)], 'Color', 'r', 'LineWidth', 4);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
indexAt2000 = find(x==2000)
efficiencyAt2000 = estimatedY(indexAt2000)
is this true?
x = [1718, 1767, 1774, 1775, 1792, 1816, 1828, 1834, 1878, 1906];
y = [0.5, 0.8, 1.4, 2.7, 4.5, 7.5, 12.0, 17.0, 17.2, 23.0];
format short e
while 1
k = input('degree of polynomial = ');
if isempty(k) % Loop is terminated
fprintf('Done') % by pressing ’’return’’
break
end
a = polyfit(x, y, k+1); % x is the year.
x = 2000;
estimatedY = polyval(a, x);
plot(x,y,'o',x,estimatedY,'-')
axis([1718 2000 0 30])
The x any y are correct. I suggest you use my code for polyfit(), polyval(), and plotting.
Like this?
x = [1718, 1767, 1774, 1775, 1792, 1816, 1828, 1834, 1878, 1906];
y = [0.5, 0.8, 1.4, 2.7, 4.5, 7.5, 12.0, 17.0, 17.2, 23.0];
plot(x,y, 'bo', 'LineWidth', 2, 'MarkerSize', 8);
[coefficients, S, mu] = polyfit(x, y, theOrder); % x is the year.
x = 1700:2050;
estimatedY = polyval(coefficients, x, S, mu);
hold on;
plot(x, estimatedY, 'r-', 'LineWidth', 2);
grid on;
yl = ylim;
line([2000 2000], [yl(1), yl(2)], 'Color', 'r', 'LineWidth', 4);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
indexAt2000 = find(x==2000)
efficiencyAt2000 = estimatedY(indexAt2000)
Djati Waluyo
2013년 5월 20일
편집: Djati Waluyo
2013년 5월 20일

THANKS TO Image Analyst :)
May Allah bless you with success, health, happiness, patience and strength..
추가 답변 (1개)
You have to know what order polynomial you want to fit. Then use polyfit().
Read the help for polyfit() to see how to use the function. Once you have the polynomial, you can just plug in the year 2000 and that will answer your question.
카테고리
도움말 센터 및 File Exchange에서 Geographic Plots에 대해 자세히 알아보기
참고 항목
2013년 5월 20일
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)

