Hello, I need to interpolate two data. One is temperature and other is CO2. I need to interpolate it on same time interval and want to see the value of both (whose value is higher than other). I have tried interp1 function and I have been through many questions and answers here but couldn't find related. I have attached my code here. I always got the error of non monotonic increasing. I have a data from last thousand of years till 2010. In that temperature and CO2 has increased and decreased in some intervals and I can't reshape as it affects on final result. If anyone can help I would say please. I
clear allload CO2data % Historical CO2 data from Harris
ageCO2=CO2data.years;fCO2=CO2data.fCO2;timeCO2=1950-ageCO2;size(timeCO2)figure(101)plot(timeCO2/1000,fCO2)xlabel('time (1000 years)')ylabel('CO2 level (ppm)')title('Historical CO2 level in the atmosphere (ppm)')load Tdata % Historical temp data from Harris
ageT=Tdata.years;Temp=Tdata.T;timeT=1950-ageT;size(timeT)figure(102)plot(timeT/1000,Temp)xlabel('time (1000 years)')ylabel('Temperature anomaly (C)')title('Historical temperature anomaly (C)')figure(103)T=plotyy(timeCO2/1000,fCO2,timeT/1000,Temp);xlabel('time ( 1000 years)')ylabel(T(1),'CO2 level (ppm)')ylabel(T(2),'historic temperature level(c)')title('Atmospheric CO2 vs Temperature level')u=interp1(fCO2,timeCO2/1000,280);new_fCO2=linspace(280,191,length(fCO2));new_timeCO2=interp1(fCO2,timeCO2/1000,new_fCO2,'spline');figure(102)plot(fCO2,timeCO2/1000,new_fCO2,new_timeCO2,'-o')
Best Answer