- %% Clearing environment
- clc;
- clear vars;
- %% Declare arrays
- % Profile-5 years
- rates_5_year_profile = [0.0:0.025:1.0]';
- factor_5_year_profile =
- zeros(length(rates_5_year_profile), 1);
- % Profile-10 years
- rates_10_year_profile = [0.0:0.025:1.0]';
- factor_10_year_profile =
- zeros(length(rates_10_year_profile), 1);
- % Profile-15 years
- rates_15_year_profile = [0.0:0.025:1.0]';
- factor_15_year_profile =
- zeros(length(rates_15_year_profile), 1);
- % Profile-20 years
- rates_20_year_profile = [0.0:0.025:1.0]';
- factor_20_year_profile =
- zeros(length(rates_20_year_profile), 1);
- % Profile-25 years
- rates_25_year_profile = [0.0:0.025:1.0]';
- factor_25_year_profile =
- zeros(length(rates_25_year_profile), 1);
- % Given values
- A = 100; % Annual payment
- %% Compute factor for the 5-year profile
- for i = 1:length(rates_5_year_profile)
- % Define the time period
- N = 5;
- % Get the interest rate for this iteration
- interest_rate = rates_5_year_profile(i,1);
- % Calculate the factor
- factor_5_year_profile(i) = A * ((1 +
- interest_rate)^N - 1) / (interest_rate * (1 +
- interest_rate)^N);
- end
- %% Compute factor for the 10-year profile
- for i = 1:length(rates_10_year_profile)
- % Define the time period
- N = 10;
- % Get the interest rate for this iteration
- interest_rate = rates_10_year_profile(i,1);
- % Calculate the factor
- factor_10_year_profile(i) = A * ((1 +
- interest_rate)^N - 1) / (interest_rate * (1 +
- interest_rate)^N);
- end
- %% Compute factor for the 15-year profile
- for i = 1:length(rates_15_year_profile)
- % Define the time period
- N = 15;
- % Get the interest rate for this iteration
- interest_rate = rates_15_year_profile(i,1);
- % Calculate the factor
- factor_15_year_profile(i) = A * ((1 +
- interest_rate)^N - 1) / (interest_rate * (1 +
- interest_rate)^N);
- end
- %% Compute factor for the 20-year profile
- for i = 1:length(rates_20_year_profile)
- % Define the time period
- N = 20;
- % Get the interest rate for this iteration
- interest_rate = rates_20_year_profile(i,1);
- % Calculate the factor
- factor_20_year_profile(i) = A * ((1 +
- interest_rate)^N - 1) / (interest_rate * (1 +
- interest_rate)^N);
- end
- %% Compute factor for the 25-year profile
- for i = 1:length(rates_25_year_profile)
- % Define the time period
- N = 25;
- % Get the interest rate for this iteration
- interest_rate = rates_25_year_profile(i,1);
- % Calculate the factor
- factor_25_year_profile(i) = A * ((1 +
- interest_rate)^N - 1) / (interest_rate * (1 +
- interest_rate)^N);
- end
- %% Plot the profiles
- figure;
- % Plot 5-year profile
- plot(rates_5_year_profile, factor_5_year_profile,
- 'r-o');
- hold on;
- % Plot 10-year profile
- plot(rates_10_year_profile,
- factor_10_year_profile, 'k-o');
- % Plot 15-year profile
- plot(rates_15_year_profile,
- factor_15_year_profile, 'y-o');
- % Plot 20-year profile
- plot(rates_20_year_profile,
- factor_20_year_profile, 'b-o');
- % Plot 25-year profile
- plot(rates_25_year_profile,
- factor_25_year_profile, 'g-o');
- title('Interest Rate vs. factor (P/100, i%, N)');
- xlabel('Interest rate (%)');
- ylabel('factor (P/100, i%, N)');
- legend('5-year profile', '10-year profile', '15-
- year profile', '20-year profile', '25-year
- profile');
- hold off;
[text] part 1
Viewer
Editor
You can edit this paste and save as new: