0% found this document useful (0 votes)
2 views7 pages

General Problems 1

The document outlines various MATLAB programming tasks, including translating a mathematical formula, calculating loan payments, computing freshwater density based on temperature, and solving simultaneous equations. It also includes programs for calculating electricity costs, steady-state current in circuits, and income tax based on taxable income. Each task is accompanied by example code and results to demonstrate functionality.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views7 pages

General Problems 1

The document outlines various MATLAB programming tasks, including translating a mathematical formula, calculating loan payments, computing freshwater density based on temperature, and solving simultaneous equations. It also includes programs for calculating electricity costs, steady-state current in circuits, and income tax based on taxable income. Each task is accompanied by example code and results to demonstrate functionality.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

1- Translate the following formula into matlab expression

ab (a + b) 14b log10 (c)


x=a+ + c a + 3c + ln(2) + + 2 sinh( β ) − 3 tanh(γ )
c ab e log10 (a + b + α )
2- Economic formulas are available to compute annual payment for loans. Suppose that
you borrow an amount of money P and agree to repay it in n annual payments at an
interest rate of i. the formula to compute the annual payment A:
i (1 + i ) n
A= P Write an m-file to compute A. Test it with P=$35,000 and an interest
(1 + i ) n − 1
rate of 7.6% (i=.076). compute results for n=1,2,3,4 and 5 and display the results as a
table with heading and columns for n and A.

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']

Results: for p=35000 i=0.076 nmax=5


n A
1 3.7660e+004
2 1.9519e+004
3 1.3483e+004
4 1.0473e+004
5 8.6738e+003

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-

x=input('enter consumption of resident=’)


if x<=500
cost=0.02*500;
else if x>500 & x<=1000
cost1=10;
cost2=(x-500)*0.05;
cost=cost1+cost2;
else
cost1=35;
cost2=(x-1000)*0.1;
cost=cost1+cost2;
end
end
tcost=cost+5

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-

inc=[5000 10000 15000 30000 50000];


for ti=inc
if ti<10000
tax=0.1*ti;
else if ti<20000
tax=1000+0.2*(ti-10000);
else
tax=3000+0.5*(ti-20000);
end
end
disp([ti tax])
end

Results:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy