The VIBES Toolbox has comprehensive plot functionality for the following classes:
vibes.TimeBlocks
vibes.TimeSeries
vibes.FreqBlocks
vibes.FRFMatrix
This tutorial focuses on the plotting capabilities of the vibes.TimeSeries
and vibes.TimeBlocks
classes.
All plot settings are available by using the property
, value
syntax. By default, the plot methods of the classes in the above scale the axes according to the units of the Channels
and/or RefChannels
.
Plotting time series
The VIBES Toolbox has many plotting capabilities to make the visualization of measurement data easier. This will be illustrated using time data from a vehicle run-up.
% Load a vibes.TimeSeries object containing the time data
TS = vibes.load(
'VIBES,Examples,Datasets'
,
'mat'
,
'i3'
,
'i3Measurement.TimeSeries.mat'
);
Create a figure and plot the Time Series. One can select specific measurement channels by inserting the channel indices as input arguments, in this example the 1st channel, corresponding to an accelerometer placed on the seat rail. The time data is plotted between 0 and 25 seconds.
vibes.figure(
'Time series'
);
TS.plot(1,[0 25]);
The first argument, the channel, accepts an array of class vibes.Channel
as well. This can be especially useful for smart selection of the channels using the find and/or select methods on the properties of the channel objects.
Here’s an example of channel matching using the name SeatRail
, corresponding to both acceleration channels.
ch_i = TS.Channels.select(
'Name'
,
'SeatRail'
);
TS.plot(ch_i,[0 25]);
Plot settings
The look of your plot can be customized using the third input argument. Use any vibes.plotStyle
format to specify properties such as the line width, marker and color. For example, plot the time series as a green dotted line of width 2:
TS.plot(1,[],
'2g:'
)
You can also specify the plot style as a structure:
S = struct();
S.LineWidth = 2;
S.Color = vibes.color(
'g'
);
S.LineStyle =
':'
;
TS.plot(1,[],S)
Plotting time blocks
The plotting settings mentioned can also be applied to the vibes.TimeBlocks
class. Additionally, a selection can be made as to which block should be plotted.
% Load a vibes.TimeBlocks object containing the same time data cut into
% 0.25 second blocks.
TB = vibes.load(
'VIBES,Examples,Datasets'
,
'mat'
,
'i3'
,
'i3Measurement.TimeBlocks.mat'
);
vibes.figure(
'Time Blocks'
);
% Select the block for which the name contains '10sec'.
bl = TB.Blocks.select(
'Name'
,
'10sec'
);
TB.plot(ch_i,bl)
Combining plot features
To visualize where the time data was cut into blocks, the vibes.TimeSeries
can be plotted together with dashed lines where the blocks start.
% Plot the time series.
TS.plot(1,[2 3.5])
% Get the start times of the blocks and plot dashed lines.
t_block = [TB.Blocks.t1];
dashedline(
'x'
,t_block)