1

I am trying to identify the model of my quadcopter using MATLAB's System Identification toolbox (App) and the command line. I have both the input and output signals which are both non-uniformly sampled, specifically, the sample time between consecutive measurements isn't constant throughout the experiment.

I found that it is possible to create a non-uniform data set on MATLAB using:

FlightData = iddata(inputs, outputs, [],'SamplingInstants', time, 'Name', dataName);

where time contains the non-uniform sampling time vector. However, I couldn't find any linear or nonlinear model on MATLAB that accepts such kind of non-uniform data.

I would appreciate if anyone could give any hints.

M.A.
  • 169
  • 1
  • 1
  • 18
  • You're not really providing much information on the data that you are trying to model... – Trogdor Sep 27 '16 at 17:39
  • 1
    Well, I didn't think that the type of data would matter, but my input data is an array of the 4 PWM (pulse width modulation) sent to the 4 motors at each time sample, and my output data is the set of Euler's angles at each sampling time describing the attitude of the quadcopter. – M.A. Sep 28 '16 at 06:50

1 Answers1

1

The support of irregular sampled data in the system identification toolbox is quite limited. Many functions of the System Identification Toolbox require regularly sampled data see this link.

From your use of iddata() I guess that your input & output data are measured pairwise at the same moment, but the timespan between adjacent samples is not regular.

In this case you can use some (linear) interpolation e.g with interp1. This can introduce some errors in the estimation, but it is a simple and fast approach. Just define the new time grid with regularly time steps and interpolate them.

% create some dummy data
time = rand(20,1);                                  % irregular sampled measurements
input = sin( 2*pi*time);                            % some input signal
output = cos( 2*pi*time );                          % some output signal

% define new time vector and interpolate input and output data
Ts = 0.01;                                          % new sampling time in seconds
newTime = min(time) : Ts : max(time);               % new time vector
inputInterp = interp1( time, input, newTime  )      % interpolated  input data
outputInterp = interp1( time, output, newTime  )    % interpolated  output data

% lets see what just happend
figure
plot( time,input,'o'), hold on
plot(time,output,'ro');

plot( newTime, inputInterp, 'x')
plot( newTime, outputInterp, 'rx')

legend({'Original Input', 'Original Output', 'Interpolated Input', 'Interpolated Output'})

should do the trick.

The errors should be small if your (original) sampling frequency is larger than the frequency of the relevant dynamics. The (rigid body) dynamics of a quadrocopter are in the order of 1 Hz, so measuring the input and output data at 50 or 100 Hz is usually fine (but this may depend on your application).

snowflake
  • 56
  • 7