Hi @esra kan
To compute the integral of an indicator function, you can indeed approximate the integral using a discrete sum and then accumulate it using the "cumsum" function. The idea is to treat the discrete time steps as small intervals and then sum over these intervals.
Here's how you can implement this:
% Define the discrete time series X_t
X_t = [0, 1, 0, 1, 2, 1, 0];
% Define the values of a_i
a_i = [0, 1, 2];
% Define the time step size (assuming equal time steps)
delta_s = 1; % Adjust this based on your specific time step
% Initialize the result matrix Y_t for each a_i
Y_t = zeros(length(a_i), length(X_t));
% Loop over each a_i value
for j = 1:length(a_i)
% Compute the indicator function for each time step
indicator = (X_t == a_i(j));
% Compute the cumulative sum to approximate the integral
Y_t(j, :) = cumsum(indicator) * delta_s;
end
disp('Y_t for each a_i:');
disp(Y_t);
Hope this helps!