Bendal, Angelo C. Bsme-2A Computer Programing
Bendal, Angelo C. Bsme-2A Computer Programing
Bendal, Angelo C. Bsme-2A Computer Programing
BSME-2A
COMPUTER PROGRAMING
1.1.2
b) ans =
a)
2
>> c = a - b
>> a = zeros(6,1)
3
a= c=
5
0 4 0 -4
0 c) 1.3.2
( 512π −0.255)
0 >> c = a .* b 1
a) θ0 = t = 0:0.1:9
0
c=
0
5 9 5 >> t = 0 : 0.1 : 9;
>> g = 9.8;
b) >> v0 = 50.75;
d)
>> b = 325 : 20 : 405 >> theta0 = 5*pi/12 - 0.255;
>> c = a ./ b
b= >> y0 = 0;
c=
325 345 365 385 405
>> x0 = 0;
5.0000 1.0000 0.2000
>> y = y0 - 0.5 * g * t.^2 + v0*sin(theta0).*t;
c) >> x = x0 + v0*cos(theta0).*t;
e)
>> a = sum(b) >> figure;
>> c = a .^2
a= >> plot(x,y);
c=
1825
>> title('y(t) vs. x(t)');
25 9 1
>> xlabel('Horizontal Distance (m)');
1.2.2 >> ylabel('Altitude (m)');
f)
a) >> grid on;
>> d = [1 2 3; 2 3 4; 4 5 6;]; d(1,:), d(:,2)
>> a = [5, 3, 1]; b = [1, 3, 5]; c = a + b
ans =
c=
1 2 3
6 6 6
b)
>> x = -pi/2 : pi/30 : 2*pi;
>> plot(x,atan(x));
>> xlabel('x');
>> ylabel('y');
>> plot(x,acot(x),'r');
>> t = 0 : 0.1 : 8;
>> g = 9.8;
1.4.2
>> v0 = 50.75; a)
>> theta0 = 5*pi/12 - 0.425; >> x = -pi/2 : pi/30 : 2*pi;
exp_Approx12 = 0;
for j=0:12
end
exp_Approx15 = 0;
for j=0:15
>> plot(n,n.*log(n),n,sqrt(n),n,log(n))
Error with 12 terms:
>> title('Big-O characteristics of Algorithms: Linear Plot')
--------------------------
>> ylabel('Estimate of Running Time')
exp(2): 1.5321e-06
>> xlabel('n (number of elements)')
1/5
>> dsolve('Dy-y = exp(2*t)','y(0)=5')
Number of Terms Needed for the function to be within the >> diff(f,2)
ans =
allowed error:
ans =
exp(2*t) + 4*exp(t)
-----------------------------------------------------------------------
0
exp(3): 13 terms | Error = 0.000324362
2.2.2 2.3.2
x - 2*log(x - 1) ans =
exp(2*t) + C3*exp(t)