Ch-3 Sol
Ch-3 Sol
Chapter (3)
Built in Matlab Function
% Chapter 3
%p3.1
A1=nthroot(-5,3)
A2=nthrooth(-5)^(1/3)
%p 3.2
x=10
b=[1:10]
log_b_x=log(x)./lod(b)
%p 3.3
P_o=100;
r=0.9;
t=10;
P=P_o*exp(r*t)
% p3.4
%find the reaction rate constantk
Q=8000; %unit of Q is cal/mol
R=1.987;
k_o=1200;
T-[100:50:500];
k=k_o*exp(-Q./(R*T))
table=[T' k']
%p3.5
Bulb=100;
no=20;
App=500;
n_A=4;
H_leaks=3000;
H_E_b=Bulb*no;
H_E_a=App*n_A;
A_C_H=H_E_b+H_E_a+H_leaks
%(b)
A_CH=2000;
No_Air_Con=round(A_C_H/Air_con_h)
% 3.6
No_way=factorial(4)
No_way=factorial(10)
Page 2 of 4
%p3.7
No_commit=nchoosek(10,2)
No_teams=nchoosek(30,11)
%p3.8
% each hand 5 cards of 52 deck cards
No_of_hands=factorial(52)/factorial(52-5)
%p3.9
No_1=length(primes(10000))
No_2=length(primes(20000))
No_prime_no=No_2-No_1
%p3.10
theta=[0:0.1:2*pi];
x=sin(theta);
y=cos(theta);
z=tan(theta);
Table=[theta',x',y',z']
%p3.11
%create a table with two columns
t=[0:10];% time in second
A=4;%maximum displacement in cm
Omega=0.6; %angular frequency in rad/s
x=A*cos(Omega*t);
Table=[t',x']
%3.12
%create a table with three columns
t=[0:10];% time in second
A=4;%maximum displacement in cm
Omega=0.6; %angular frequency in rad/s
x=A*cos(Omega*t);
a=-A*(Omega^2)*cos(Omega*t);
Table=[t',x',a']
%p3.13
%calculate the height of the building
d=120;% distance to the building in m
Theta_max=(30+3)*(pi/180); %maximum angle converted to
radian
Theta_min=(30+3)*(pi/180); %minimum angle converted to
radian
h_max=d*tan(Theta_max)
h_min=d*tan(Theta_min)
Page 3 of 4
%p3.14
% calculate the angle from the ground
d=20; % distance to the building in feet
h=200; % height in feet
Theta_R=atan(h/d); % angle in radian
Theta=Theta_R*(180/pi) % angle in degree
%p3.15
% Calculate the maximum temperature measured by each
thermocouple
Thermocouple_1=[84.3 86.4 85.2 87.1 83.5 84.8 85.0 85.3
85.3 85.2 82.3 84.7]; %temperature measured for
thermocouple1
Thermocouple_2=[90.0 89.5 88.6 88.9 88.9 90.4 89.3
89.5 88.9 89.1 89.5 89.4 89.8]; %temperature
measured for thermocouple 2
Thermocouple_3=[86.7 87.6 88.3 85.3 80.3 82.4 83.4
85.4 86.3 85.3 89.0 87.3 87.2]; %temperature
measured for thermocouple 3
Max_Thermocouple_1=max(Thermocouple_1)
Max_Thermocouple_2=max(Thermocouple_2)
Max_Thermocouple_3=max(Thermocouple_3)
%b
Min_Thermocouple_1=min(Thermocouple_1)
Min_Thermocouple_1=min(Thermocouple_1)
Min_Thermocouple_1=min(Thermocouple_1)
%p3.16
% Show the maximum range of an object
g=9.81; %in m/s^2
v_o=100; %initial velocity m/s
Theta=[0:pi/100:pi/2]; %angle velocity with values range
between 0 and pi/2
Range=(v_o^2/g)*sin(2*Theta); % calculate the range
[Max_Range,col]=max(Range) %calculate the max value of
the range and the max value column No.
Max_Rande_temp=Theta(col)% determine the angle
%p3.20
%(a)
%Generate values from the uniform distribution
r(1) = rand();
%on the interval (1, 6)
r(1) = 1 + (6-1)*r(1);
%integer
r(1) = round(r(1))
Page 4 of 4
%(b)
r(2) = round(1 + (6-1).*rand())
%(c)
total = r(1) + r(2)
%p3.22
% Calculate the current in the circuit
Z_L=0+5i; % inductance impedance
Z_C=complex(0,-15); % capacitor impedance
Z_R=5+0i; %resistor
Z_T=Z_L+Z_C+Z_R; %total impendance
V=10+0i;
I=V/Z_T
%p3.23
% Calculate Z_C and Z_L in the circuit
f=15e03;
L=200e-03;
C=1e-06;
Omega=2*pi*f;
X_L=Omega*L;
X_C=1/(Omega*C);
Z_L=complex(0,X_L)
Z_C=complex(0,-X_C)
%b
Z_R=5+0i;
Z_T=Z_L+Z_C+Z_R
%C
% Calculate the current in the circuit
V=0+10i;
I=V/Z_T