output = '##p: 2\n##id: yw\n';
%Q1
600 * (1 + 0.04) .^ [0 1 7 15]
output = [output '##1: ' mat2str(ans) '\n'];
%Q2
[300 400 500 800 900]' * (1 + 0.12) .^ [0 1 7 15]
output = [output '##2: ' mat2str(ans) '\n'];
%Q3
(100:100:7400)' .* (1 + 0.04) .^ [0 1 7 15]
output = [output '##3: ' mat2str(ans) '\n'];
%Q4
[18 38 54 85 98] / (163 * 5/9 * (38 + 459.67))
output = [output '##4: ' mat2str(ans) '\n'];
%Q5
59 ./ (163 * 5/9 * ((0:4:100)' + 459.67))
output = [output '##5: ' mat2str(ans) '\n'];
%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))
output = [output '##6: ' mat2str(ans) '\n'];
%Q7
[-2 3 8; 0.5 * (1 + erf(([-2 3 8] - 3) / (5 * sqrt(2))))]
output = [output '##7: ' mat2str(ans) '\n'];
%Q8
[-22:5:28; 0.5 * (1 + erf(((-22:5:28) - 3) / (5 * sqrt(2))))]
output = [output '##8: ' mat2str(ans) '\n'];
%Q9
x = -7:0.2:13;
[x; 0.5 * (1 + erf((x - 3) / (5 * sqrt(2))))]
output = [output '##9: ' mat2str(ans) '\n'];
%Q10 and write to file
output = [output '##10: None'];
file = fopen('P2.txt', 'wt');
fprintf(file, output);
fclose(file);