matlabdiscrete-mathematicsnumerical-integrationgalois-field

What is wrong in this Discrete Integration with Galois Fields in Matlab


I want to implement Discrete Integration with Galois Fields in Matlab where the time step is not constant. Assume that it is this:

enter image description here

My attempt

function [ int ] = integrate_matlab( YDataVector, a, b )
%integrate_matlab Calculate the discrete integral
%   Discrete Matlab Integration
%   int_1^N x(t_k) * (b-a)/N, where t_k = a + (b-a) k/N
%
%   YDataVector - Galois vector (255 x 1 gf), this is signal,
%   which values you can reach by YDataVector.x
%
%   int - returns Galois vector (255 x 1 gf)

N = length(YDataVector);
for k=1:N
    tk = a + (b - a) * k/N;
    int = xtk(YDataVector, k) * (b - a) / N;   
         %   How to implement the function xtk(YDataVector)?
end

and then the function xtk

function [ xtk_result ] = xtk( YDataVector, k )
%xkt Summary of this function goes here
%   YDataVector - Galois vector (255 x 1 gf), this is signal
%   xtk_result - Galois vector (255 x 1 gf)
%   k - index, this must be here to be able calculate different xtk for different iterations

    xtk_result = ; //  I do not know what to fill here

end

I am confused by the mathematical series equation x(tk) for tk. I know that I am doing now this wrong. The writing x(tk) just confuses me, since I think it as a function that takes in the series. I know that it is a signal at some time point, here the YDataVector, but how to implement it I have forgotten. I should probably iterate the series first:

t_0 = a;
t_1 = a + (b - a) * 1/N;

This does not seem to help, since tk is not defined iteratively.

What am I thinking wrong when implementing the series x(tk)?


Solution

  • Assuming that t contains the time that corresponds to each element of x (stored in YDataVector.x). Then if I understood correctly your question you can get x_tk with something like this :

    N = length(YDataVector.x) ;
    k = 1 : N;
    tk = a + (b-a)* k/N ;
    x_tk = interp1(t,YDataVector.x,tk);