% Matlab program to calculate transient heat flow in a heated dike over time using fourier transforms (fft) % Notes: find how to set "double precision" to all values clear all; figure(1); %%%%%% PARAMETERS %%%%%% % (Matlab already has "pi" set to 3.1416, try it!) n=32 % choose a number which is a exponent of 2 kapp = d = start_temp = time = % you will change this value for each time interval %%%%%% SET STARTING TEMPERATURE PROFILE (from 1 to n)%%%%%% %(Hint: you may need to include an "antidike" to keep your boundary conditions) % for j = 1,n T = end plot(T,n,'^') hold on plot(T,n) xlabel('distance (units)') ylabel('Temperture (units)') Title('Heated Dike, Lab #3, #...days') %%%%%% TAKE FAST FOURIER TRANSFORM (FFT) of your Temp function %%%% % (You are now working in frequency (or in this case - wave number) space % (This will output a coefficient in alternating sine,cos for each point) dfft(T,n) %%%%% GET FOURIER COEFFICIENTS (Bo, An, Bn) %%%%%% COEFF(1) = T(1)/2 COEFF(2) = T(2)/2 for j = 3:2:n % increment from 3 to n by 2's COEFF(j) = T(j) COEFF(j+1) = T(j+1) end %%%%%% SOLVE FOR TEMPERATURE CHANGE using solution to heatflow eqn %%%%% for j = 3:2:n NEWT = T(j).*exp(put relevant stuff here) NEWT = T(j+1).*exp(stuff here) end NEWT = T(2)*exp(stuff here) %%%%%% Recover TEMP function by taking INVERSE FOURIER TRANSFORM %%%%% % (This will bring you back to Temperature and time space) % % and plot your final conductive temperture profile! % ift(NEWT,n) plot(n,NEWT,'or') plot(n,NEWT,'r') hold off