[Note]If you used the 'info' option with d3readswv, X.x will be empty because this kind of read is just getting the sensor information and not the data.. X.x is…" />

DTAG 4 – Data Structure

All of the methods from the previous page for reading in sensor data will produce a structure, X, that contains three fields: X.x, X.fs, and X.cn [Note]If you used the 'info' option with d3readswv, X.x will be empty because this kind of read is just getting the sensor information and not the data..

X.x is the sensor data, stored in a cell array with one sensor channel per cell to allow for differently-sized vectors [Note]Because each sensor can have a different sampling rate, the number of samples in each sensor array over the deployment can be different.. You access members of a cell array in Matlab/Octave using the curly parenthesis {} rather than the usual round brackets (). For example, to access the 8th sensor channel and make it into a variable p, you do:

MATLAB
p = X.x{8};
R
ADD CODE HERE

For multiple sensor channels, e.g. to extract the data for the three accelerometer axes, the format is:

MATLAB
A = [X.x{1:3}];
R
ADD CODE HERE

X.fs is the sampling rate of each sensor channel in Hz (samples per second). X.fs is a vector with the number of each sensor channel.

X.cn is a vector with the id numbers for each sensor channel, which are usually used by internal functions rather than directly by the user. These are the id numbers the DTAGs use to figure out what kind of data is in each channel. For example, use d3channames(X) to find out which channels are present in X and in what order. From this you may find out that the pressure sensor data is, for example, in channel 8.

At this point, we would have all the information we need to plot the raw dive profile, using the plott function found within the animaltags toolbox:

MATLAB
plott(X.x{8},X.fs(8))
R
ADD CODE HERE

We may find that the plot doesn’t make sense compared to what we expect the animal to be doing. Depending on the tag, the depth numbers may be too small or too large. This is because most of the data that comes off the tag is not calibrated. Calibration values need to be applied to each channel of X.x to convert the data into familiar units and this is the topic of Section 4. But first you need to organize the metadata for the deployment using Section 3.

Previous: Reading the Data

Next: Metadata