ModStat PSet 1
ModStat PSet 1
ModStat PSet 1
Part 4
>> q = 2*pi*300*401*(100-20)/log(5/3)
q =
1.1838e+08
2. Finding a Function
3. Temperature Conversion
4. Financial planning
(a)
>> format BANK
>> 1000*1.07^(25)
ans =
5427.43
(b)
function [amt] = partb(years)
format BANK;
amt = 0;
count = 1;
while count <= years
amt = amt + 1000;
amt = amt * 1.07;
count = count + 1;
end
end
>> partb(40)
ans =
213609.57
(c)
Case 1: Save $1000/yr for 10 years. Interest for last 30 years.
>> partb(10)
ans =
14783.60
>> ans*1.07^(30)
ans =
112536.53
Case 2: Nothing for 10 years, then $1000/year for 30 years.
>> partb(30)
ans =
101073.04
(d)
Case 1:
function [acct] = partd1(years)
acct = 5000000;
format BANK;
count = 1;
gains = 0;
while count <= years
acct = acct - 200000;
acct = acct * 1.1;
count = count + 1;
gains = gains + 1;
if gains == 4
acct = acct - 200000;
acct = acct * 0.96;
count = count + 1;
end
end
end
>> partd1(20)
ans =
17469934.03
Case 2:
function [acct] = partd2(years)
acct = 5000000;
format BANK;
count = 1;
gains = 0;
while count <= years
acct = acct - 250000;
acct = acct * 1.1;
count = count + 1;
gains = gains + 1;
if gains == 4
acct = acct * 0.96;
count = count + 1;
end
end
end
>> partd2(20)
ans =
15500866.24
5. Mass Balance
6. Collatz Sequence
(a)
function [length] = collatz(numb)
a = [numb];
count = 2;
while numb ~= 1
if mod(numb,2) == 0
a(count) = numb/2;
numb = a(count);
count = count + 1;
else
a(count) = (numb*3) + 1;
numb = a(count);
count = count + 1;
end
end
length = count - 2;
end
(b)
(c)
>> collatz(4)
ans =
2.00
>> collatz(47)
ans =
104.00
>> collatz(92)
ans =
17.00
(d)