We started the day with interpolation and went it means. Matlab does this easily with the interp1 command. However there are many types of interpolation like cubic, linear and spline to name a few. We then move onto a practical example using the thermodynamic properties, here is a picture:
 |
| Thermodynamic properties example. |
We then discussed curve fitting and talked about polyfit and polyval. We also talked abut smoothing out the graph to make it look nicer.
Conclusion:
Interpolation is important part of data graphing since it fills the hole in data. Interpolating beyond data archived is tricky. Polyfit and polyval are good ways of finding the curve fits of data to better represent what is going on.
%% HMWK 15 - 1
y = x.^3+2*x.^2-x+3 %y function
x = [-1:0.2:1] %x length of 11
area = trapz(x,y) %trapz function
area1 = quad('x.^3+2*x.^2-x+3',-1,1) %area of quad
area2 = quadl('x.^3+2*x.^2-x+3',-1,1) %area of quad1
t = [0:1]
%HMWK 15 - 2
syms y(t) %syms for y function
y(t) = dsolve(diff(y,t) == t^2+y, y(0)==0) %y function solver at t = 0
aa = subs(y(t),'t',[0:1]) %%subs t 0 to 1 for y solved eq
double(aa(2)) %double answers to see
%HMWK 15 - 3
syms u(x)
u(x) = dsolve(diff(u,x,3) == u(x))
aa = subs(u(x),'x',[0:1])
Du = diff(u, x);
D2u = diff(u, x, 2);
u(x) = solve(diff(u, x, 3) == -u/2*u'',u(0) == 0)