[text] part 1

Viewer

  1. %% Clearing environment
  2. clc;
  3. clear vars;
  4. %% Declare arrays
  5. % Profile-5 years
  6. rates_5_year_profile = [0.0:0.025:1.0]';
  7. factor_5_year_profile =
  8. zeros(length(rates_5_year_profile), 1);
  9. % Profile-10 years
  10. rates_10_year_profile = [0.0:0.025:1.0]';
  11. factor_10_year_profile =
  12. zeros(length(rates_10_year_profile), 1);
  13. % Profile-15 years
  14. rates_15_year_profile = [0.0:0.025:1.0]';
  15. factor_15_year_profile =
  16. zeros(length(rates_15_year_profile), 1);
  17. % Profile-20 years
  18. rates_20_year_profile = [0.0:0.025:1.0]';
  19. factor_20_year_profile =
  20. zeros(length(rates_20_year_profile), 1);
  21. % Profile-25 years
  22. rates_25_year_profile = [0.0:0.025:1.0]';
  23. factor_25_year_profile =
  24. zeros(length(rates_25_year_profile), 1);
  25. % Given values
  26. A = 100; % Annual payment
  27. %% Compute factor for the 5-year profile
  28. for i = 1:length(rates_5_year_profile)
  29. % Define the time period
  30. N = 5;
  31. % Get the interest rate for this iteration
  32. interest_rate = rates_5_year_profile(i,1);
  33. % Calculate the factor
  34. factor_5_year_profile(i) = A * ((1 +
  35. interest_rate)^N - 1) / (interest_rate * (1 +
  36. interest_rate)^N);
  37. end
  38. %% Compute factor for the 10-year profile
  39. for i = 1:length(rates_10_year_profile)
  40. % Define the time period
  41. N = 10;
  42. % Get the interest rate for this iteration
  43. interest_rate = rates_10_year_profile(i,1);
  44. % Calculate the factor
  45. factor_10_year_profile(i) = A * ((1 +
  46. interest_rate)^N - 1) / (interest_rate * (1 +
  47. interest_rate)^N);
  48. end
  49. %% Compute factor for the 15-year profile
  50. for i = 1:length(rates_15_year_profile)
  51. % Define the time period
  52. N = 15;
  53. % Get the interest rate for this iteration
  54. interest_rate = rates_15_year_profile(i,1);
  55. % Calculate the factor
  56. factor_15_year_profile(i) = A * ((1 +
  57. interest_rate)^N - 1) / (interest_rate * (1 +
  58. interest_rate)^N);
  59. end
  60. %% Compute factor for the 20-year profile
  61. for i = 1:length(rates_20_year_profile)
  62. % Define the time period
  63. N = 20;
  64. % Get the interest rate for this iteration
  65. interest_rate = rates_20_year_profile(i,1);
  66. % Calculate the factor
  67. factor_20_year_profile(i) = A * ((1 +
  68. interest_rate)^N - 1) / (interest_rate * (1 +
  69. interest_rate)^N);
  70. end
  71. %% Compute factor for the 25-year profile
  72. for i = 1:length(rates_25_year_profile)
  73. % Define the time period
  74. N = 25;
  75. % Get the interest rate for this iteration
  76. interest_rate = rates_25_year_profile(i,1);
  77. % Calculate the factor
  78. factor_25_year_profile(i) = A * ((1 +
  79. interest_rate)^N - 1) / (interest_rate * (1 +
  80. interest_rate)^N);
  81. end
  82. %% Plot the profiles
  83. figure;
  84. % Plot 5-year profile
  85. plot(rates_5_year_profile, factor_5_year_profile,
  86. 'r-o');
  87. hold on;
  88. % Plot 10-year profile
  89. plot(rates_10_year_profile,
  90. factor_10_year_profile, 'k-o');
  91. % Plot 15-year profile
  92. plot(rates_15_year_profile,
  93. factor_15_year_profile, 'y-o');
  94. % Plot 20-year profile
  95. plot(rates_20_year_profile,
  96. factor_20_year_profile, 'b-o');
  97. % Plot 25-year profile
  98. plot(rates_25_year_profile,
  99. factor_25_year_profile, 'g-o');
  100. title('Interest Rate vs. factor (P/100, i%, N)');
  101. xlabel('Interest rate (%)');
  102. ylabel('factor (P/100, i%, N)');
  103. legend('5-year profile', '10-year profile', '15-
  104. year profile', '20-year profile', '25-year
  105. profile');
  106. hold off;

Editor

You can edit this paste and save as new:


File Description
  • part 1
  • Paste Code
  • 23 Apr-2024
  • 3.09 Kb
You can Share it: