General Problems 1
General Problems 1
3- The density of freshwater can be computed as a function of temperature with following cubic
equation:-
ρ = 5.5289 × 10−8 Tc3 − 8.5016 × 10−6 Tc2 + 6.5622 × 10−5 Tc + 0.99987
0
Where:- ρ = density ( g cm ) Tc = temperature ( C )
3
Use matlab to generate vector of temperatures ranging from 320 F to 93.20 F using
0
increment of 3.5 F . Convert this vector to degrees Celsius and then compute a vector of
densities based on the cubic formula. Create a plot of ρ versus Tc .
5
Recall that:- Tc = (TF − 32)
9
4- write matlab program to calculate value of y
n!
y= ∑
n
k = 2 k!( n + k )
(
z 2 xz + n h − k / h )
Assume n=9 x=15 z=k/n h=0.75
5- - Write m-file to solve the following tri diagonal set of simultaneous equations:-
4 x1 + x 2 =4
x1 + 4 x 2 + x 3 = 11
x 2 + 4x 3 + x 4 = 15
x 3 + 4x 4 + x 5 = 18
x 4 + 4x 5 + x 6 = 21
x5 + 4 x 6 + x 7 = 24
x 6 + 4x 7 + x 8 = 27
x 7 + 4x 8 + x 9 = 30
x 8 + 4 x 9 + x 10 = 37
x 9 + 4 x10 = 45.5
6- The electricity accounts of residents in very small town are calculated as
follows:-
- if 500 units or less are used the cost is 2 cents per unit
- if more than 500 but not more than 1000 units are used, the cost is $10
for first 500 units and then 5 cents for every unit in excess of 500
- if more than 1000 units are used, the cost is $35 for the first 1000 units
plus 10 cents for every unit in excess of 1000.
- in addition, a basic service fee of $5 is charged, no matter how much
electricity is used.
Write computer program to enter the consumption of resident and to
calculate and display the total charge for any resident.
7-
The steady-state current I following in a circuit that contains resistance R , capacitance C
and inductance L in series is given by:
E
I=
2
2 1
R + 2πωL −
2πωC
Where E = input voltage= 2
ω = angular frequency
Assume C=10 and L=4 plot the variation of current with angular frequency for different
resistances 2 , 17 and 37.
Take ω = 1 to 12 with increment 0.5
8-
Write program to calculate the income tax on the following taxable income (dollars):
5000, 10000, 15000, 30000, and 50000
Solution:-
1-
x=a+a*b*(a+b)/(c*sqrt(abs(a*b)))+c^a+sqrt(14)*b/exp(3*c)+log(2)+…
log10(c)/log10(a+b+alpha)+2*sinh(beta)-3*tanh(gama)
2-
clc
p=input('a mount of money = ')
i=input('interest rate = ')
nmax= input('max value of n= ')
for m=1:nmax
a(m)=p*i*(1+i)^m/((1+i)^m-1);
n(m)=m;
end
clc
format short e
[n' a']
3-
tf=32:3.5:93.2
tc=5*(tf-32)/9;
den=5.5289e-8*tc.^3-8.5016e-6*tc.^2+6.5622e-5*tc+0.99987;
plot(tc,den)
4-
clc
n=9;
x=15;
h=0.75;
y(1)=0.0;
for k=2:n
z=k/n;
nf=prod(1,n);
kf=prod(1,k);
nk=nf/(kf*(n+k));
y1=nk*(z^2)*(x*z+n^h-k/h);
y(k)=y1+y(k-1);
end
res=y(n)
Results:
res=
1.6529e+000
5-
a=[4 1 0 0 0 0 0 0 0 0
1410000000
0141000000
0014100000
0001410000
0000141000
0000014100
0000001410
0000000141
0 0 0 0 0 0 0 0 1 4];
b=[4;11;15;18;21;24;27;30;37;45.5];
x=a\b
Results:
x=
5.0000 e-001
2.0000 e+000
2.5000 e+000
3.0000 e+000
3.5000 e+000
4.0000 e+000
4.5000 e+000
5.0000 e+000
5.5000 e+000
1.0000 e+001
6-
7-
e=2;
c=10;
l=4;
w=1:0.5:12
for n=1:3
r=input('value of resistance =')
i=e./sqrt(r^2+(2*pi*l.*w-1./(2*pi*c.*w)).^2)
plot(w,i)
hold on
end
xlabel('angular frequency ')
ylabel('Curent')
hold off
0.08
0.07
0.06
0.05
Curent
0.04
0.03
0.02
0.01
0
1 2 3 4 5 6 7 8 9 10
angular frequency
8-
Results: