x = (100/120)^(1/5)
i = 1/x - 1

% Next, I create a row vector of ages
ages = [40, 28, 30, 27]

% I can also avoid commas
ages2 = [18 20 26]

%{
    There is an index associated to each element
    that starts from position 1.
    For example in second position we have 28
%}
ages(2)

% I change the age in position 2
ages(2) = 27

% To compute the number of elements, I use the
% function length()
length(ages)
length(ages2)

% I can access the last position in different ways
ages(4)
ages(length(ages))
ages(end)

% Same thing for the next to last position
ages(3)
ages(length(ages) - 1)
ages(end - 1)

% Column vector
years = [2012; 2015; 2022; 2023]

% or
years2 = [2013 2014 2019 2021]'

A = [1 2 3; 4 5 6]

% A transpose
A'

% Exercise 24: The irr function
cf = [-100000, 10000, 20000, 30000, 40000, 50000]
i = irr(cf)

% Exercise 25 bis: the xirr function (we think in
% terms of years)
cf = [-30 -20 28 32]
dates = ["01/01/2023", "01/01/2025", "06/01/2025", ...
    "01/01/2026"]
i = xirr(cf, dates)

% Exercise 25: the xirr function (we think in
% terms of months)
cf = [-30 -20 28 32]
dates = ["01/01/2023", "03/01/2023", "03/15/2023", ...
    "04/01/2023"]
i = xirr(cf, dates)