Receiving error vectors must be the same length when trying to plot.
Afficher commentaires plus anciens
I'm trying to model Earth's surface temperature with the radiative forcing of CO2 changing through time. For years 1600-1744 (i called them 1:144 interms of t in my code) [CO2]is constant, in 1745-1953 (145:358 interms of t in my code) [C02] is increasing by 0.068%/year, in 1954-2100 (359:500 in terms of t in my code) [CO2] is increasing by 0.4%. I have a function that I'm referencing which calculates the change in atmospheric emissivity redulting from the change in [CO2].
my function I'm referencing:
function e = eps_atm(CO2)
e = 0.8*(1+(0.0541*log(CO2/280)));
end
%% CO2 variation Climate Model %%
%set up constants
so = 1360; %units = W/m2
albedo = 0.3; %units = none
sigma = 5.67*10^-8; %units = W/((m^2)*(K^4))
p = 997; %units = kg/m^3
cw= 4181; %units = J/(kg*K)
h = 100; %units = m3
a = 0.0514; %units = none
co2 = 280; %units = none
deltat = 31556700; %units = seconds
nsteps = 500; %nsteps from i.c.
T(1) = 250; %units = K
for t = 1:nsteps
hold on;
if t == 1:144
T(t+1)= (((1+eps_atm(280)/2)*((so*(1-albedo))/4)-(sigma*T(t)^4))/(p*cw*h))*deltat+T(t);
elseif t == 145:358
T(t+1)= (((1+eps_atm(280*(1+0.00068*((t)-143)))/2)*((so*(1-albedo))/4)-(sigma*T(t)^4))/(p*cw*h))*deltat+T(t);
elseif t == 359:500
T(t+1)= (((1+eps_atm(280*(1+0.004*((t)-357)))/2)*((so*(1-albedo))/4)-(sigma*T(t)^4))/(p*cw*h))*deltat+T(t);
end
end
figure(1)
hold on;
time = [1:nsteps+1]*deltat;
plot(time/31556700, T,'x')
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Map Display dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!