Sei sulla pagina 1di 5

% final exam

% John Bressan
% 103799357

%Q1
%a
format compact
A=quad(@(x)int1(x),-1,1,1e-6)
Ix=quad(@(x)int2(x),-1,1,1e-6)
%A=
% 1.8683
% Ix =
% 4.6072

%b
F=dblquad(@(x,y)force1(x,y),0,3,0,4,1e-6)
xc=dblquad(@(x,y)posx(x,y),0,3,0,4,1e-6)
yc=dblquad(@(x,y)posy(x,y),0,3,0,4,1e-6)
%F=
% 24.0000
% xc =
% 2
% yc =
% 1.3333

%Q2
t=[0,10,20,30,40,50,60,70,80,90,100,110,120];
h=[-8,241,1244,2872,5377,8130,11617,15380,19872,25608,31412,38309,44726];
v=diff(h)./diff(t);
tn=t(1:length(t)-1);
a=diff(v)./diff(tn);
tnew=tn(1:length(tn)-1);
%v=
% Columns 1 through 6
% 24.9000 100.3000 162.8000 250.5000 275.3000 348.7000
% Columns 7 through 12
% 376.3000 449.2000 573.6000 580.4000 689.7000 641.7000
%a=
% Columns 1 through 6
% 7.5400 6.2500 8.7700 2.4800 7.3400 2.7600
% Columns 7 through 11
% 7.2900 12.4400 0.6800 10.9300 -4.8000
figure(1)
plot(t,h,'o',t,h,'g')
figure(2)
plot(tn,v,'o',tn,v,'g')
figure(3)
plot(tnew,a,'o',tnew,a,'g')

%Q3
%a
r=[0,0.8,1.2,1.4,2,3,3.4,3.6,4,5,5.5,6.37];
den=[13000,12900,12700,12000,11650,10600,9900,7500,6300,4750,4500,3300];
a=fminsearch(@(a)Earth(a),[0,0])
%a=
% 1.0e+04 *
% -0.0266 1.2487

%b
% m=quad(@(r)mass1(r),0,6370,1e-6)
%m=
% -7.0026e+21

clear,clc
%Q4
Y=0.00237;A=7e-4;g=32.2;
E=Y*(A/2);
[tn,yn]=ode45(@(t,y)rocket1(t,y,g,A,Y,E),[0,250],[0,200]);
ymax=max(yn(:,1));
yplace=length(yn(ymax,:));
tmax=tn(yplace,1)

%Q5
Dtdr=-7.3e3;
Tend=0;
dtg1=fzero(@(dtg)pipe2(Tend,dtg),1)
[rn1,Tn1]=ode45(@(r,T)pipe1(r,T),[1e-2,3.5e-2],[600,dtg1])
figure(4)
plot(rn1,Tn1(:,1))

function [ dT ] = pipe1( r )
dT(1)=T(2);
dT(2)=-T(2)/r;
dT=dT';
end

function [ f2 ] = int2( x )
f2=0.5*((2*sqrt(1-x.^2)+cos(pi/2*x)).^2).*(2.*(1-x.^2)-cos(pi/2.*x));
end

function [ res ] = pipe2( Tend,dtg )


[rn,Tn]=ode45(@(r,T)pipe1(r,T),[1e-2,3.5e-2],[600,dtg]);
n=length(rn);
TendGuess=Tn(n,1);
res=Tend-TendGuess;
end

function [ dy ] = rocket1( t,y,g,A,Y,E )


if t<=7
m=(0.0573*(7-t)+0.02)
else
m=0.02
end
dy(1)=y(2);
dy(2)=-g-E/m*(y(2)).^2
dy=dy'
end

function [ d ] = mass1( r )
a=fminsearch(@(a)Earth(a),[0,0]);
d=(a(1).*r.^2+a(2)).*4*pi.*r.^2;
end

function [ f1 ] = int1( x )
f1=2*sqrt(1-x.^2)-cos(pi/2.*x);
end
function [ p ] = force1( x,y )
p=2/3*x*(4-y);
end

function [ p1 ] = posx( x,y )


F=dblquad(@(x,y)force1(x,y),0,3,0,4,1e-6);
p1=2/3*x.^2*(4-y)./F;
end

function [ p2 ] = posy( x,y )


F=dblquad(@(x,y)force1(x,y),0,3,0,4,1e-6);
p2=2/3*x.*(4-y).*y./F;
end

function [ f ] = Earth( a )
r=[0,0.8,1.2,1.4,2,3,3.4,3.6,4,5,5.5,6.37];
den=[13000,12900,12700,12000,11650,10600,9900,7500,6300,4750,4500,3300];
f=sum((den-a(1)*r.^2-a(2)).^2);
end

+ 3 figures I couldn’t download on mac

Q1(a)
wrong answer for Ix (-0.5)
error in int2 function formula (-0.5)
Q1(b)
Total (7/8)

question5
-0.5 line76 incorrect value of Tend
-2 line4(pipe2), replace n,1 by n,2
-0.5 line1(pipe1), T is missing
total 9/12

Question 4 
-1 no plot
Total 11/12

Q3(a) -1 wrong units of vector r


Q3(b) -2 wrong function mass1.m
          -1 wrong answer
Total: 16/20
Q2 :
8/8

Potrebbero piacerti anche