I have 2 values of population say 30000 for 2001 and 50000 for 2011, I want the population values for all the years between 2001 to 2011 following the trend of population rise from 2001 to 2011

1 回表示 (過去 30 日間)
do I use the extrapolation technique for this? If so how?

採用された回答

sixwwwwww
sixwwwwww 2013 年 10 月 12 日
Dear Sourangsu,Using interplotation you can do like this:
Known_year = [2001 2011];
Known_year_population = [30000 50000];
Unknown_year = 2002:2010;
Unknown_year_population = interp1(Known_year, Known_year_population, Unknown_year);
year = 2001:2011;
population = [30000 Unknown_year_population(:,:) 50000];
plot(year, population, 'o-'), title('Population vs. Year'), xlabel('Year'), ylabel('Population')
Good luck!

その他の回答 (1 件)

Image Analyst
Image Analyst 2013 年 10 月 12 日
I hope this isn't homework - I'm assuming you're honest when you didn't apply the "homework" tag. Here is a solution using polyfit. Don't be scared - it's really only 3 lines - most of the code is just to make a fancy graph.
order = 1; % Whatever...
years = [2001, 2011];
population = [30000, 50000];
% Main part of the code is the next 3 lines:
coefficients = polyfit(years, population, order);
fittedYears = 2001 : 1 : 2011; % Years you want to estimate.
estimatedPopulation = polyval(coefficients, fittedYears)
% Now plot
fontSize = 20;
plot(fittedYears, estimatedPopulation, 'rs-', 'LineWidth', 2);
hold on;
plot(years, population, 'bo', ...
'MarkerSize', 15, 'LineWidth', 3); % Training set.
grid on;
xlabel('Year', 'FontSize', fontSize);
ylabel('Population', 'FontSize', fontSize);
title('Demo by ImageAnalyst', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
% Give a name to the title bar.
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off')

カテゴリ

Help Center および File ExchangeGraphics Performance についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by