Using MatLab interpolation to create a function with specific target value
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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?
0 Commenti
Risposte (1)
Star Strider
il 28 Giu 2012
I'm not sure the interpolation approach will get you where you want to go, but then I've never done anything similar to what you're doing. I plotted the (x,y) data that you give to the spline fit, and it looks to me as though you could model it with something like:
f = @(K,t) ( K(1).*t .* exp(K(2).*t) );
f = @(K,t) ( K(1) .* exp(K(2).*t) .* sin(K(3) + K(4).*t) );
or some such, fitting it to your existing data with 'lsqnonlin' or one of the others. Integrate the fitted objective function analytically (or numerically using 'trapz' or 'cumtrapz'), and perhaps use one of the other optimisation routines to adjust some or all of the parameters to fit the integrated model that best fits your 1GtC data to match your 2GtC and higher data. (This assumes that the same general model is appropriate for 2GtC and higher data.) Then evaluate those functions to provide the data to give to your climate model.
0 Commenti
Vedere anche
Categorie
Scopri di più su Interpolation in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!