% m-file demonstrating diurnal variation of soil temperature % Brian Hornbuckle, January 16, 2007. clear; % always important to do, make sure variables are reset % --------- variables z = 0.05; % depth into soil, m t = linspace(0,48,1000); % time variable, hours % type "help linspace" at the command line to % find out what linspace does Tave = 15; % average surface temperature, deg C A = 5; % amplitude, deg C D = 0.05; % damping depth, m omega = pi/12; % radian frequency, rad hour^-1 % -------------- calculations T = Tave + A.*exp(-z./D).*sin(omega.*(t-8)-z./D); % soil surface temperature % -------- figures figure(1) plot(t,T); grid on; % notice that you can put more than one command on a line axis([0 48 5 25]); % use this to make the figure look better (center on data) xlabel('time, hours'); ylabel('soil surface temperature, \circC'); set(gca,'XTick',[0:4:48]); % put x tick marks every 4 hours % for more practice, try to recreate Figure 2.5 in Campbell and Norman.