A reactor is thermally stratified as in the following table
A reactor is thermally stratified as in the following table: write a matlab script to determine the temperature of the reactor at any depth value between 0 meters to 2 meters using quadratic splines. The following criteria should be included in your program Display the quadratic splines graphically, as shown in the figure below.
Solution
Following is the script file for given problem:
d=input(\'Enter the value of depth between 0 to 2m for which temperature is to calculated \');
D=[0 1 1.5 2];
T=[70 55 22 13];
cs=csapi(D,T);
fnplt(cs,2);
hold on
plot(D,T,\'or\')
xlabel(\'Depth, m\');
ylabel(\'Temperature, degree Celcius\');
x=polyfit(D,T,2);
k=polyval(x,d);
disp([\'Value of temperature at depth \',num2str(d),\' m is = \',num2str(k),\' deg Celcius\'])
