Sie sind auf Seite 1von 11

ENME 337

ASSIGNMENT #4
Name: Uday Karri
Lab Section: B02
Date: October 15, 2013

Part A: Output
Please enter the temperature value in degrees F:30
Please enter the windspeed in mi/h:42
The wind chill temperature is: 13 degrees F.
The output for Q2 is:
years
monthly payment total payment
10.00
1053.34 126400.61
11.00
979.04 129232.91
12.00
917.38 132103.25
13.00
865.46 135011.41
14.00
821.17 137957.19
15.00
783.00 140940.34
16.00
749.79 143960.61
17.00
720.68 147017.75
18.00
694.96 150111.46
19.00
672.11 153241.46
20.00
651.70 156407.43
21.00
633.37 159609.05
22.00
616.84 162846.00
23.00
601.88 166117.91
24.00
588.28 169424.44
25.00
575.88 172765.22
26.00
564.55 176139.85
27.00
554.16 179547.96
28.00
544.61 182989.14
29.00
535.81 186462.98
30.00
527.69 189969.06
The output for Q10 is:
Interest Rate ACC Value
2.00 12189.94
2.50 12800.85
3.00 13439.16
3.50 14105.99
4.00 14802.44
4.50 15529.69
5.00 16288.95
5.50 17081.44
6.00 17908.48
The output for Q13 is:
n(months)
B
% loan Paid
0 20000.00
0
6.00 18278.92
8.61

12.00
18.00
24.00
30.00
36.00
42.00
48.00
54.00
60.00

16501.14
17.49
14664.80
26.68
12767.96
36.16
10808.63
45.96
8784.76
56.08
6694.22
66.53
4534.80
77.33
2304.25
88.48
0.21
100.00

The output for Q15 is:


The minimum time and its corresponding y value: 59.2946 s , 37 m
Ratio of Sin(phi) and Sin(alpha)is 3.065826
Ratio of vrun and v swim is 3.000000
The output for Q23 is:
Force 1= -6.928203 (Compressive Force)
Force 2= 3.464102 (Tensile Force)
Force 3= 6.928203 (Tensile Force)
Force 4= -6.928203 (Compressive Force)
Force 5= -1.154701 (Compressive Force)
Force 6= 7.505553 (Tensile Force)
Force 7= 1.154701 (Tensile Force)
Force 8= -8.082904 (Compressive Force)
Force 9= 8.082904 (Tensile Force)
Force 10= 4.041452 (Tensile Force)
Force 11= -8.082904 (Compressive Force)
The output for Q24 is:
0.50
-0.10
-10.00
-2.00
10.00

The output for Q25 is:


0.3873
0.15
0.59161
0.35
0.70711
0.5
0.83666
0.15
0.92195
0.85
a0= -0.062355
a1= -9.575025
a2= 102.466773
a3= -249.042975
a4= 166.936208

0.0225 0.003375 0.00050625


0.1225 0.042875 0.015006
0.25
0.125
0.0625
0.0225 0.003375 0.00050625
0.7225 0.61412 0.52201

Part B: Code
% Assignment #4
% Name: Uday Karri
% ID: 10078524
% Lab Section: B02
%clearing all variables and screen
clc
clear
%Question 1
% ask user for inputs:
T = input('Please enter the temperature value in degrees F:');
v = input('Please enter the windspeed in mi/h:');
%Write the equation out:
Twc = 35.74+0.6215*T-35.75*v^0.16+0.4275*T*v^0.16;
roundedTwc = round(Twc); %round function

fprintf('The wind chill temperature is: %g degrees F.\n', roundedTwc) %final


sentence shows the wind chill temp.
%Question 2
format bank %formats for easy visualization.
%define variables:
y = 10:30;
r = 4.85/100;
P = 100000;
%equations using element by element operations due to the presence of matrices:
M = (P.*(r./12))./(1-(1+r./12).^(-12.*y));
T = M.*y.*12;
disp('The output for Q2 is:')
disp(' years
monthly payment total payment')
MatrixA = [y' M' T']; %combining everything into a matrix to display in the proper
format as per question.
disp(MatrixA);
%Question 10
%define variables:
A = 10000;
r = 2:0.5:6;
n = 10;
%equations using element by element operations due to the presence of matrices:
B = A.*(1+(r./100)).^n;
%combining everything into a matrix to display in the proper format as per
question.
MatrixB = [ r' B'];
disp('The output for Q10 is:')
disp(' Interest Rate ACC Value')
disp(MatrixB)
%Question 13
format bank
%define variables:
A = 20000;
r = 6.5;

P = 391.32;
n = 0:6:60;
rate = r/1200; %extracting pieces that will be repeated in the next equation.
%equations using element by element operations due to the presence of matrices:
B = A.*(1+(rate)).^n - ((P/rate).*((1+rate).^n - 1));
Paid = ((A-B)./A)*100;
%combining everything into a matrix to display in the proper format as per
question.
MatrixC = [n' B' Paid'];
disp('The output for Q13 is:')
disp('n(months)
B
% loan Paid')
disp(MatrixC)
%Question 15
%define variables:
vrun = 3;
vswim = 1;
L = 48;
ds = 30;
dw = 42;
y = 20:48; %range of y values are given using colon operator with an increment of 1.
%equations using element by element operations due to the presence of matrices:
Ds = sqrt(ds.^2+y.^2);
Dw = sqrt(dw.^2+(L-y).^2);
trun = Ds./vrun;
tswim = Dw./vswim;
Totaltime = trun+tswim;
Minimumtime = min(Totaltime); %finding the minimum time from the total time
matrix.
indexminimum = find(Totaltime == Minimumtime); %retrieving the index of the
minimum time.
ymin = y(indexminimum); %equating the corresponding y index and retrieving the
designated value.
disp('The output for Q15 is:')

fprintf('The minimum time and its corresponding y value: %g s , %g m


\n',Minimumtime,ymin)
%calculating the angles:
phi = atand(ymin/ds);
Sinephi = sind(phi);
alpha = atand((L-ymin)/dw);
Sinealpha = sind(alpha);
Snell1 = Sinephi/Sinealpha;
fprintf('\nRatio of Sin(phi) and Sin(alpha)is %f\n',Snell1)
Snell2 = vrun/vswim;
fprintf('\nRatio of vrun and v swim is %f\n',Snell2)
%Question 23:
V = sqrt(3)/2;
A = [0.5 1 0 0 0 0 0 0 0 0 0;
V 0 0 0 0 0 0 0 0 0 0;
-0.5 0 0.5 1 0 0 0 0 0 0 0;
-V 0 -V 0 0 0 0 0 0 0 0;
0 -1 -0.5 0 0.5 1 0 0 0 0 0;
0 0 V 0 V 0 0 0 0 0 0;
0 0 0 -1 -0.5 0 0.5 1 0 0 0;
0 0 0 0 -V 0 -V 0 0 0 0;
0 0 0 0 0 -1 -0.5 0 0.5 1 0;
0 0 0 0 0 0 V 0 V 0 0;
0 0 0 0 0 0 0 -1 -0.5 0 0.5;];
B = zeros(1,11);
B(2) = -6;
B(6) = 5;
B(10) = 8;
X = A\B';
Sig = sign(X); %assign the signs of matrix X to vector Sig. Return 1 for positive sign
and -1 for negative.
disp('The output for Q23 is:')
for i=1:1:11
fprintf('\nForce %d= %f',i,X(i)) %formats how the Force is shown.

if(Sig(i)==1) %if sign is positive, outputs tensile. If it is negative, outputs


compressive.
disp(' (Tensile Force) ')
else
disp(' (Compressive Force) ')
end
end
%Question 24:
%define x and y vectors:
X = [-4 -2 0.2 1 4];
Y = [-7.6 -17.2 9.2 -1.6 -36.4]';
%Matrix F:
F_x = [X(1)^4 X(1)^3 X(1)^2 X(1)
X(2)^4 X(2)^3 X(2)^2 X(2)^1
X(3)^4 X(3)^3 X(3)^2 X(3)^1
X(4)^4 X(4)^3 X(4)^2 X(4)^1
X(5)^4 X(5)^3 X(5)^2 X(5)^1

1;
1;
1;
1;
1;];

%find the solution:


C = F_x\Y;
disp('The output for Q24 is:')
disp(C)
%Question 25:
format short g
%define variables and vectors:
c = 1;
t = 0.2;
x = [0.15 0.35 0.5 0.7 0.85];
y = [0.08909 0.9914 0.08823 0.06107 0.03421]';
%extract constants for easy visualization.
Constant = (t*c)/0.2;
MatrixD = [sqrt(x(1)/c) x(1)/c (x(1)/c)^2 (x(1)/c)^3 (x(1)/c)^4;
sqrt(x(2)/c) x(2)/c (x(2)/c)^2 (x(2)/c)^3 (x(2)/c)^4;

sqrt(x(3)/c) x(3)/c (x(3)/c)^2 (x(3)/c)^3 (x(3)/c)^4;


sqrt(x(4)/c) x(1)/c (x(1)/c)^2 (x(1)/c)^3 (x(1)/c)^4;
sqrt(x(5)/c) x(5)/c (x(5)/c)^2 (x(5)/c)^3 (x(5)/c)^4];
A = Constant*MatrixD;
%Solve:
X = inv(A)*y;
disp('The output for Q25 is:')
disp(MatrixD)
%Display solution:
for i = 0:1:4
fprintf('\n a%d= %f',i,X(i+1))
end
%Chapter 5:
%Question 19:
%Define initial conditions.
R_o = 6.4;
L_o = 25;
A_o = (pi*R_o^2)/4;
%Create a force vectors:
F = [0 13345 26689 40479 42703 43592 44482 44927 45372 46276 47908 49035
50265 53213 56161];
L = [25 25.037 25.073 25.113 25.122 25.125 25.132 25.144 25.164 25.208 25.409
25.646 26.084 27.398 29.150];
Sigma_e = F/A_o;
Eps_e = (L-L_o)./L_o;
Sigma_t = (F./A_o).*(L./L_o);
Eps_t = log(L./L_o);
plot(Eps_e, Sigma_e, '-b');
title('Stress-Strain Curves');
xlabel('Strain');
ylabel('Stress');

hold on
plot(Eps_t, Sigma_t, '-r');
legend('engineering','true');
hold off
%Question 24:
c = 1.5; %cord length in meters.
t = 0.2; %maximum thickness as a fraction of cord length.
x = [0:0.01:1.5];
y1 = (t*c/0.2)*((0.2969*sqrt(x/c))-(0.1260*(x/c))(0.3516*(x/c).^2)+(0.2843*(x/c).^3)-(0.1015*(x/c).^4));
y2 = -(t*c/0.2)*((0.2969*sqrt(x/c))-(0.1260*(x/c))(0.3516*(x/c).^2)+(0.2843*(x/c).^3)-(0.1015*(x/c).^4));
plot(x,y1,'-b');
hold on %using the hold command to add the second plot to the same graph.
plot(x,y2,'-b');
hold off
title('Shape of symmetrical four digit NACA airfoil', 'FontSize', 14);

Das könnte Ihnen auch gefallen