Tuesday, October 20, 2015

Day 13 - Symbolic math

 We started the day with structure array example, finishing he one from last class. We then move on to a symbolic algebra example with the use of  𝑘=𝑘𝑜𝑒−𝑄/𝑅𝑇. Here is a picture:
Symbolic example in class.
We then move onto manipulation symbolic expressions. We then move on to a ballistic problem. Here is a picture:
Ballistic problem part 1.

 Conclusion:
We again worked with structure array to get a better understanding. We spent the rest of the time using symbolic math to solve problems. Let matlab do all the hard algebra is a good idea.



%hmwk 13

%hmwk 13-1
format short eng
syms pi f m g L I
eq1 = 2*pi*f == sqrt(m*g*L/I) %eq of penduilum
solve (eq1,'L') %solve for L
%hmwk 13 - 2
syms v0 t th g
dx = sym('v0*t*cos(th)')
dx1 = subs(dx,{v0,th},{100,(pi/4)})
dy = sym('v0*t*sin(th)-.5*g*t^2')
dy1 = subs(dy,{v0,g,th},{100,9.8,(pi/4)})
ezplot(dx1,dy1,[0,20])
title('ballastic distance')
xlabel('distance in meters')
ylabel('height in meters')
t = [0:.5:20]
%% 13 - 3
syms t
h = -0.12*t^4 + 12*t^3 - 380*t^2 + 4100*t +220
v = diff(h) %diff of h = velocity
acc = diff(v) %diff of velocity = accel
ans1 = max(double(solve(h,'t'))) %for real alt
ans2 = max(double(solve(v,'t'))) %for real velocity
ans3 = max(double(solve(acc,'t'))) %for real accleration
subplot(2,2,1)  %plot alt
ezplot(h,[0:48])
title('altitude')
xlabel('time')
ylabel('height in meters')
subplot(2,2,2) %plot speed
ezplot(v,[0:48])
title('velocity')
xlabel('time')
ylabel('speed')
subplot(2,2,3) %plot acc
ezplot(acc,[0:48])
title('acceleration')
xlabel('time')
ylabel('acc')
hmaxt =solve(v,'t')
hmax=real(max(double(subs(h,'t',hmaxt)))) %max height 17000 when third v = 0
%% 13- 4
syms f x n
f = sym(20*x) %force
work = int(f,'0','n-1') %work eq
% work = 10*(n-1 )^ 2
w2 = subs(work,'n','2') %sub in 2 feet for n
w3 = max(double(solve('25 = 10*(n-1)^2'))) %amount streched
%% 13 - 5
syms x tan(x)
y = sym('tan(x)')
y1 = int(y)     %int of tanx
eq1 = matlabFunction(y1) %matlab function
fplot(eq1,[-5,5]) %fplot of a function


No comments:

Post a Comment