Thursday, December 10, 2015

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])

No comments:

Post a Comment