Instructions
Requirements and Specifications
Source Code
clc, clear all, close all
%% Question a
fprintf("***** QUESTION a) *****\n");
Ti = 25; % Initial temperature
F = 10; % Ambient temperature
K = 0.05; % Conduction coefficient
dt = 1; % Time step
% Declare the tie vector
t = 0:dt:100;
% Create a vector T that will store the temperatures for each tim step
T = zeros(length(t),1);
T(1) = Ti;
% Now calculate
for i = 1:length(t)-1
T(i+1) = T(i) + K*dt*(F-T(i));
end
% Now plot
figure
plot(t, T), grid on
xlabel('Time (minute)')
ylabel('Temperature (ºC)')
title('Temperature vs Time');
% Display
fprintf("The temperature at t = %d minutes is T = %.2f ºC\n", t(end), T(end));
%% Question b
fprintf("\n\n***** QUESTION b) *****\n");
% Variable to store the sum
terms_sum = 0;
% Now compute
for k = 1:15
terms_sum = terms_sum + (5*k^2 - 2*k);
end
% Display
fprintf("The sum of the first 15 terms in the series is %d\n", terms_sum);