Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Constrained Interpolation in Matlab

tch2tch2 Posts: 7Member
I am trying to develop several cumulative carbon emissions to later upload to a climate model. The goal is to design curves whose yearly emissions will sum to a specific cumulative emissions (eg 1 Gigaton C, 2 Gigaton C, etc), and mesh with the historical cumulative emissions (347 GtC).

For example,

In the case of the 1 GtC curve, I am looking to employ MatLab's interpolation capabilities to create a function whose annual cumulative emissions will sum to (1000-347 = 653 GtC) by a specific year (lets say 2100). I am planning to include several intermediate values (one at the start of the curve, one for the maximum annual emissions, and the end point (the year that annual emissions fall to zero).

Is there any way to do such a thing?

I have figured out how to create an emissions curve without worrying about the specific cumulative emissions and have included the MatLab code here:

%load Historical.xlsx data
load Historical.csv;
F=Historical;
Y=F(:,1);
M=F(:,2);
G=F(:,3);
%plot Historical data
%plot(Y,G)
%title('Global Estimated Annual CO_2 Emissions')
%xlabel('Year')
%ylabel('Global Estimated Annual CO_2 Emissions (GtC)')

%spline interpolator using ten intermediate values
x = 2008:10:2098;
y = [8.75 10.5 12.0 11.25 9.75 7.5 4.5 2.25 0.75 0]
cs = spline(x,[0 y 0]);
xx = linspace(2008,2098,101);
plot(x,y,'o',xx,ppval(cs,xx),'-')%

%cumulative emissions for future portion of curve
S=spline(x,y,2009:2098);
Y2=2009:1:2098;

%plot curve with both historical and future emissions
plot(Y,G,Y2,S)
title('Global Estimated Annual CO_2 Emissions')
xlabel('Year')
ylabel('Global Estimated Annual CO_2 Emissions (GtC)')
legend('Historical(1751-2008)','Future(2009-2098)')

%Total Cumulative Emissions (1751-2098)
T1=cumsum(G)
T2=cumsum(S);
T3= T1(257) + T2(90)

The idea is to modify this, such that I can force the interpolator to create a function where T3 will equal 1000 (i.e the integral of the curve equals 1000 Gt)?
Sign In or Register to comment.