Thursday, December 10, 2015

The Last Post Ever

Well this is me signing off. What did you expect? Some long farewell?

Final



































































































































All of this and so much more :c

3rd and final Project


The Project's Final Form, a beast in its own right as long as the code works out which was set into motion the day the project was due. For something that seemed relatively easy to program, this project took over 36 hours of coding alone so our data was not the most reliable seeing as how the temperature  probe did not record the correct temp during the entire process. 

My contributions varied far and vast for this project, and while most of my coding was ultimately thrown to the wayside, it was the foundation for what we got at the end. Though to be fair it was mostly just suggestions for how to code the project instead of me being the one at the computer. I guess I have some issue using someone else's computer.

As far as design and construction, I made suggestions for how the incubator should be built, though few were taken I did manage to force some ideas into the final project but mostly the design was jointly agreed upon from the start. Construction was done in tandem so we can share the credit on that nonsense.

Now here's where most of my contribution really shines is the presentation. While the ideas were created by the both of us, I was the one who created the powerpoint. Every graphic, animation, sound effect, everything was implemented by me, with consent though. I'm not the type of person who would spring these amazing presenting powers on my partner when they first see it.



The initial design of our incubator, made while I was sick mind you, at the brewery that I work at no less.

Matlab home work 15

Contents

PROBLEM #1

clear,clc

x = linspace(-1,1,11);
y = x.^5 + 2*x.^2 - x + 3;

int_trap = trapz(x,y)
int_quad = quad('x.^5 + 2*x.^2 - x + 3',-1,1)
int_quadl = quadl('x.^5 + 2*x.^2 - x + 3',-1,1)
int_trap =

    7.3600


int_quad =

    7.3333


int_quadl =

    7.3333

PROBLEM #2

clear,clc

syms y(t)
y(t) = dsolve(diff(y,t) == t^2 +y, y(0) == 0)
Y = subs(y(t),t,[0,1])
 
y(t) =
 
2*exp(t) - 2*t - t^2 - 2
 
 
Y =
 
[ 0, 2*exp(1) - 5]
 

PROBLEM #3

clear,clc

syms f(x) h1 h2 h3
h1(x) = f
h2(x) = diff(f,x)
h3(x) = diff(f,x,2)
V = odeToVectorField(2*diff(f,3) == -f*diff(f,2))
M = matlabFunction(V,'vars',{'x','Y'})

sol = ode45(M,[0,1],1)
 
h1(x) =
 
f(x)
 
 
h2(x) =
 
diff(f(x), x)
 
 
h3(x) =
 
diff(f(x), x, x)
 
 
V =
 
           Y[2]
           Y[3]
 -(Y[1]*Y[3])/2
 

M = 

    @(x,Y)[Y(2);Y(3);Y(1).*Y(3).*(-1.0./2.0)]

Index exceeds matrix dimensions.

Error in symengine>makeFhandle/@(x,Y)[Y(2);Y(3);Y(1).*Y(3).*(-1.0./2.0)]



Error in odearguments (line 87)
f0 = feval(ode,t0,y0,args{:});   % ODE15I sets args{1} to yp0.

Error in ode45 (line 113)
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...

Error in Homework15 (line 28)
sol = ode45(M,[0,1],1)

matlab homework 14

Contents

Problem #1 - Interpolation

clear,clc

V = [1 2 3 4 5 6];
P = [2494 1247 831 623 499 416];

Linear_P = interp1(V,P,3.8)
Spline_P = interp1(V,P,3.8,'spline')
Linear_V = interp1(P,V,1000)
Linear_V = interp1(P,V,1000,'spline')
Linear_P =

  664.6000


Spline_P =

  657.4373


Linear_V =

    2.5938


Linear_V =

    2.4779

Problem #2 - Curve Fitting

clear,clc
V = [1 2 3 4 5 6];
P = [2494 1247 831 623 499 416];

%polyfit gives you the coefficients.
%polyval plugs in values for 'x' and solves for each.
Y1 = polyval(polyfit(V,P,1),V);
Y2 = polyval(polyfit(V,P,2),V);
Y3 = polyval(polyfit(V,P,3),V);
Y4 = polyval(polyfit(V,P,4),V);
plot(Y1)
hold on
plot(Y2)
plot(Y3)
plot(Y4)
plot(V,P,'o')
new_V = 1:0.2:6; %higher data precision for V
int_P = interp1(V,P,new_V); %interpolate in order to get values in between V's
plot(new_V,int_P,'g')
legend('1st Order','2nd Order','3rd Order','4th Order','Actual','Interpolated')
title('Pressure vs. Volume')
xlabel('Volume (m^3)')
ylabel('Pressure (kPa)')
% 4th order polynomial seems to do the best job of fitting the data

Problem #3 - Curve Fitting II

clear,clc

V = [1 2 3 4 5 6];
P = [2494 1247 831 623 499 416];

Y = polyfit(1./V,P,1)
T = Y(1)/8.314

new_V = 1./V;
plot(new_V,P)
title('Pressure vs. Inverse Volume')
xlabel('1/V (m^-3)')
ylabel('Pressure (kPa)')
Y =

   1.0e+03 *

    2.4940   -0.0000


T =

  299.9715



Matlab homework13

Contents

%  % PROBLEM #1

syms f m g L l
Y = sym('2*pi*f = sqrt(m*g*L/l)')
solve(Y,L)
 
Y =
 
2*pi*f == ((L*g*m)/l)^(1/2)
 
 
ans =
 
(4*pi^2*f^2*l)/(g*m)
 

PROBLEM #2

clear,clc

syms v0 theta t g

X = v0*t*cos(theta)
Y = v0*t*sin(theta)-0.5*g*t^2

dX = subs(X,{t,v0,theta},{[0:20],100,pi/4})
dY = subs(Y,{t,v0,theta,g},{[0:20],100,pi/4,9.8})

ezplot(dX)
hold on
ezplot(dY)
 
X =
 
t*v0*cos(theta)
 
 
Y =
 
t*v0*sin(theta) - (g*t^2)/2
 
 
dX =
 
[ 0, 50*2^(1/2), 100*2^(1/2), 150*2^(1/2), 200*2^(1/2), 250*2^(1/2), 300*2^(1/2), 350*2^(1/2), 400*2^(1/2), 450*2^(1/2), 500*2^(1/2), 550*2^(1/2), 600*2^(1/2), 650*2^(1/2), 700*2^(1/2), 750*2^(1/2), 800*2^(1/2), 850*2^(1/2), 900*2^(1/2), 950*2^(1/2), 1000*2^(1/2)]
 
 
dY =
 
[ 0, 50*2^(1/2) - 49/10, 100*2^(1/2) - 98/5, 150*2^(1/2) - 441/10, 200*2^(1/2) - 392/5, 250*2^(1/2) - 245/2, 300*2^(1/2) - 882/5, 350*2^(1/2) - 2401/10, 400*2^(1/2) - 1568/5, 450*2^(1/2) - 3969/10, 500*2^(1/2) - 490, 550*2^(1/2) - 5929/10, 600*2^(1/2) - 3528/5, 650*2^(1/2) - 8281/10, 700*2^(1/2) - 4802/5, 750*2^(1/2) - 2205/2, 800*2^(1/2) - 6272/5, 850*2^(1/2) - 14161/10, 900*2^(1/2) - 7938/5, 950*2^(1/2) - 17689/10, 1000*2^(1/2) - 1960]
 
Error using inlineeval (line 14)
Error in inline expression ==> matrix([[0, 50.*2.^(1./2), 100.*2.^(1./2), 150.*2.^(1./2), 200.*2.^(1./2), 250.*2.^(1./2), 300.*2.^(1./2), 350.*2.^(1./2), 400.*2.^(1./2), 450.*2.^(1./2), 500.*2.^(1./2), 550.*2.^(1./2), 600.*2.^(1./2), 650.*2.^(1./2), 700.*2.^(1./2), 750.*2.^(1./2), 800.*2.^(1./2), 850.*2.^(1./2), 900.*2.^(1./2), 950.*2.^(1./2), 1000.*2.^(1./2)]])
 Undefined function 'matrix' for input arguments of type 'double'.

Error in inline/feval (line 33)
        INLINE_OUT_ = inlineeval(INLINE_INPUTS_, INLINE_OBJ_.inputExpr, INLINE_OBJ_.expr);

Error in ezplotfeval (line 51)
    z = feval(f,x(1));

Error in ezplot1ezplot1 (line 472)
    [y, f, loopflag] = ezplotfeval(f, x);

Error in ezplot (line 144)
                [hp, cax] = ezplot1(cax, f{1}, vars, labels, args{:});

Error in sym/ezplot (line 61)
   h = ezplot(fhandle(f));

Error in Homework13 (line 18)
ezplot(dX)

PROBLEM #3

clear,clc

syms t
H = -0.12*t^4 + 12*t^3 - 380*t^2 + 4100*t + 220
V = diff(H,t)
A = diff(V,t)
time = double(solve(H,t))
subplot(3,1,1)
ezplot(H,[0,52])
title('Height vs time')
ylabel('Height')
xlabel('Time')
subplot(3,1,2)
ezplot(V,[0,52])
title('Velocity vs time')
ylabel('Velocity')
xlabel('Time')
subplot(3,1,3)
ezplot(A,[0,52])
title('Acceleration vs time')
ylabel('Acceleration')
xlabel('Time')
time1 = solve(V,t)
height = double(subs(H,t,time1));
max_height = real(double(max(height)))

PROBLEM #4

clear,clc

syms x n

F = sym('20*x')

W = int(F,'0','n-1')

W2 = subs(W,'n','2')
W3 = max(double(solve('25 = 10*(n-1)^2')))

PROBLEM #5

clear,clc

A = sym('tan(x)')
int_A = int(A)
ezplot(int_A,[-5,5])

MatLAB home Work 12

Contents

PROBLEM 1

clear,clc

syms x X
ex1 = x^2-1;
EX1 = sym('X^2-1');
eq1 = sym('x^2 = 1');
EQ1 = sym('X^2 = 1');

one = subs(ex1,x,4)
two = subs(EX1,X,4)
three = subs(eq1,x,4)
four = subs(EQ1,X,4)

% one = 15
% two = 15
% three = 16==1
% four = 16==1
 
one =
 
15
 
 
two =
 
15
 
 
three =
 
16 == 1
 
 
four =
 
16 == 1
 

PROBLEM 2

V = 0:2:10;

V1 = subs(ex1,x,V)
V2 = subs(EX1,X,V)
V3 = subs(eq1,x,V)
V4 = subs(EQ1,X,V)

% This works for the V1 and V2, which have whole intergers place inside
% their vecotrs. For V3 and V4, each vector component is an equality of two
% numbers that don't make any sense.
 
V1 =
 
[ -1, 3, 15, 35, 63, 99]
 
 
V2 =
 
[ -1, 3, 15, 35, 63, 99]
 
 
V3 =
 
[ 0 == 1, 4 == 1, 16 == 1, 36 == 1, 64 == 1, 100 == 1]
 
 
V4 =
 
[ 0 == 1, 4 == 1, 16 == 1, 36 == 1, 64 == 1, 100 == 1]
 

PROBLEM 3

clear,clc

syms a b c A B C x X
ex4 = a*x^2 + b*x + c;
EX4 = sym('A*X^2 + B*X +C');
eq4 = sym('a*x^2 + b*x + c = 0');
EQ4 = sym('A*X^2 + B*X + C = 0');

x_ex = subs(ex4,{a b c x},{3 4 5 [0:0.5:5]})
X_EX = subs(EX4,{A B C X},{3 4 5 [0:0.5:5]})
x_eq = subs(eq4,{a b c x},{3 4 5 [0:0.5:5]})
X_EQ = subs(EQ4,{A B C X},{3 4 5 [0:0.5:5]})

% all results are symbolic
 
x_ex =
 
[ 5, 31/4, 12, 71/4, 25, 135/4, 44, 223/4, 69, 335/4, 100]
 
 
X_EX =
 
[ 5, 31/4, 12, 71/4, 25, 135/4, 44, 223/4, 69, 335/4, 100]
 
 
x_eq =
 
[ 5 == 0, 31/4 == 0, 12 == 0, 71/4 == 0, 25 == 0, 135/4 == 0, 44 == 0, 223/4 == 0, 69 == 0, 335/4 == 0, 100 == 0]
 
 
X_EQ =
 
[ 5 == 0, 31/4 == 0, 12 == 0, 71/4 == 0, 25 == 0, 135/4 == 0, 44 == 0, 223/4 == 0, 69 == 0, 335/4 == 0, 100 == 0]
 

PROBLEM 4

clear,clc

syms f m g L I

Y = sym('((2*pi)*f = sqrt((m*g*L)/I))')

L = solve(Y,L)
 
Y =
 
2*pi*f == (-L*g*m*1i)^(1/2)
 
 
L =
 
(pi^2*f^2*4i)/(g*m)
 

PROBLEM 5

clear,clc

syms mt mb x

water = sym('50 = 0.2*mt + 0.65*mb');
ethanol = sym('0 = -100*x + 0.35*mt + 0.25*mb');
methanol = sym('50 = 100*x + 0.45*mt + 0.1*mb');

[x,mass_top,mass_bottom] = solve([water,ethanol,methanol],[x,mt,mb])
 
x =
 
0.28333333333333333333333333333333
 
 
mass_top =
 
33.333333333333333333333333333333
 
 
mass_bottom =
 
66.666666666666666666666666666667