In: Computer Science
So the problem is to create a plot of points and plot them using only 'o' and no lines then using the polyfit and polyval functions, find a first order equation to curve fit the points (and plot it on the existing plot).
I got that part and have the following code
clear
clc
%define measured data
temp = [250 300 340 400 460 500 540 600 660 700 750 810 930 1000
1120]
HC= [.791 .846 .895 .939 .978 1.014 1.046 1.075 1.102 1.126 1.148
1.169 1.204 1.234 1.328]
%calculate new HC values using polyfit and polyval
p=polyfit(temp,HC,1)
y1=polyval(p,temp)
%plot original data & 1st order curve
plot(temp,HC,'o')
hold on
plot(temp, y1)
The next part though is giving me trouble: Once you have found the slope and intercept, use those values to find the Heat capacity when the temperature is 800 and display the answer.
Executable code:
clear
clc
%define measured data
temp = [250 300 340 400 460 500 540 600 660 700 750 810 930
1000 1120];
HC= [.791 .846 .895 .939 .978 1.014 1.046 1.075 1.102 1.126
1.148 1.169
1.204 1.234 1.328];
%calculate new HC values using polyfit and polyval
p=polyfit(temp,HC,1)
y1=polyval(p,temp);
%plot original data & 1st order curve
plot(temp,HC,'o')
hold on
plot(temp, y1)
%heat capacity when temperature is 800, where slope and
%intercept are 0.0006 and 0.7075 .it is in variable p
HC_800=(0.0006*800)+0.7075