Extending regression lines beyond data span

11 views (last 30 days)
Hi everyone,
I'm working on a code that would predict Arctic ice coverage during the rest of the 21st century, like so:
%load ice coverage data
data = load('Ice_North.txt');
%define variables
year = data(:,1);
data_month(:,1:12) = data(:,2:13); %a new matrix with monthly values only
%calculate the yearly average time series
yearData = nanmean(data_month,2);
%plot yearly averaged time series
plot(year, yearData, 'LineWidth',2,'Color','b')
ylabel('Sea ice coverage (milions of km^2)')
grid on
title('Annual average Arctic sea ice coverage')
%regression analysis
coeff1 = polyfit(year,yearData,1);
f1 = polyval(coeff1,year);
hold on
coeff2 = polyfit(year,yearData,2);
f2 = polyval(coeff2,year);
hold on
legend('Data','Linear interpolation','Quadratic interpolation')
I would like to extend both linear and quadratic interpolations, so that they reach up to, for example 2100. Any advice on how to do that?
All the best,
Scott MacKenzie
Scott MacKenzie on 8 May 2021
Great. Thanks very much. Very nice work.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by