%Q1
600 * (1 + 0.04) .^ [0 1 7 15]
writematrix(ans,'P2Q1A.txt')
%Q2
[300 400 500 800 900]' * (1 + 0.12) .^ [0 1 7 15]
writematrix(ans,'P2Q2A.txt')
%Q3
(100:100:7400)' .* (1 + 0.04) .^ [0 1 7 15]
writematrix(ans,'P2Q3A.txt')
%Q4
[18 38 54 85 98] / (163 * 5/9 * (38 + 459.67))
writematrix(ans,'P2Q4A.txt')
%Q5
59 ./ (163 * 5/9 * ((0:4:100)' + 459.67))
writematrix(ans,'P2Q5A.txt')
%Q6 using outer product trick
1 ./ (163 * 5/9 * ((0:3:99)' + 459.67)) * (0:2:100)
%Q6 using meshgrid, preferred way to do this
[p, t] = meshgrid(0:2:100, 0:3:99);
p ./ (163 * 5/9 * (t + 459.67))
writematrix(ans,'P2Q6A.txt')
%Q7
[-2 3 8; 0.5 * (1 + erf(([-2 3 8] - 3) / (5 * sqrt(2))))]
writematrix(ans,'P2Q7A.txt')
%Q8
[-22:5:28; 0.5 * (1 + erf(((-22:5:28) - 3) / (5 * sqrt(2))))]
writematrix(ans,'P2Q8A.txt')
%Q9
x = -7:0.2:13;
[x; 0.5 * (1 + erf((x - 3) / (5 * sqrt(2))))]
writematrix(ans,'P2Q9A.txt')