0

I have a signal vector of size 1-by-1155 obtained by an accelerometer sensor. An example of values in this vector is [0.5301 1.0039 1.4751 1.520]. I also have the time vector (size 1-by-983) which is the time duration of gathering the data measured in seconds (so it's increasing with increment 1)

When gathering the data it was sampled at a sample frequency fs = 102.4 Hz (sampling time Ts = 0.0098 s).

I want to use MATLAB to discretize the signal, by using this formula: x[n] = x(n*Ts).

Questions: Is n in this formula the number of signal points I have obtained (e.g. 1155)? What sampling time will I use in the formula? Because I guess it wont be the same sampling time used when obtaining the signal from the sensor (e.g. 0.0098s)?

How would I easily implement this equation in MATLAB? I tried with the code below but I'm not certain about the implementation since I'm using n = i = 1155 here:

% allocate a vector for the discretized signal
disc_x = [zeros(length(x),1)];
% Loop through each element
for i = 1: length(x)
    disc_x(i) = x(i)/fs;
end

Any help would be appreciated.

Adriaan
  • 17,741
  • 7
  • 42
  • 75
Ckjh
  • 1

1 Answers1

0

Firstly, the size of the time vector is different to the size of the signal vector. Secondly, you need to check the time intervals in your time vector. Are they all equal? Is this time interval smaller than the sampling interval Ts? Assuming the time interval equal to Ts, then your signal is already discretized. This is disc_x is equal to x. Otherwise, you might need to average, or interpolate, depending of the type of discretization.