Skip to content

Histogram2

Alexius Wadell edited this page Jan 17, 2017 · 1 revision

Syntax

ds.Histogram2(ChannelX, ChannelY, [minValueX, maxValueX; minValueY, maxValueY])

ds.Histogram(__, Name, Value)

Description

ds.Histogram(ChannelName, [minValue, maxValue]) creates a bivariate histogram plot of ChannelY vs ChannelX using the supplied datasources (ds). The bivariate histogram is limited to ChannelX values between minValueX and maxValueX; and ChannelY values between minValueY and maxValueY

ds.Histogram(__, Name, Value) Additional optional parameters can be passed to the Histogram2 using Name-Value pairs

Input Arguments

ChannelX

The name of the x-axis channel used to generate the bivariate histogram plot. For a list of possible channel see allLogged.

ChannelY

The name of the y-axis channel used to generate the bivariate histogram plot. For a list of possible channel see allLogged.

[minValueX, maxValueX; minValueY, maxValueY]

Histogram will only look at values between the minValue and maxValue, samples outside of that range will be ignored.

It is recommended to start with a range significantly larger than the anticipated range. Once an initial histogram has been generated, further refinements can be made to the values of minValue and maxValue as needed.

The range for ChannelX is given by minValueX and maxValueX.

The range for ChannelY is given by minValueY and maxValueY.

Name-Value Pair Arguments

'unit' -- Unit System

Sets the units used to report the channel values. Specified as a cell array {unitX, unitY}, where unitX is the units for ChannelX and unitY is the units for ChannelY.

See getChannel for more information about unit conversions.

'nBins' -- Number of Bins

Number of bins used to generate the histogram, specified as two positive integer: [nBinsX, nBinY]. Where nBinX is the number of bins for ChannelX and nBinY is the number of bins for ChannelY.

Defaults to 50 bins on both axes.

'Normalization' -- Type of Normalization

Normalization methods used, specified to one of following:

Normalization Description
'count' The height of each bar is the number of observations in each bin
'probability' The height of each bar is the number of observations in each bin divided by the total number of observations. The sum of the bars height's is one
'pdf' Default Normalization. The height of each bar is (number of observations) / (total observations * area of bin). The sum of the bars volumes is one.

Examples

Goal: Generate a G-G Circle using datasources from the 2016 FSAE Michigan competition.

First poll Datamaster for datasources from the competition

dm = Datamaster;

%Get Datasource that occurred during the competition (May 10-15th 2016)
ds = dm.getDatasource('StartDate', '2016-05-10', 'EndDate', '2016-05-15');

Using dm.allLogged, we find that the channel for longitudinal acceleration is called 'G_Force_Long', and the channel for lateral acceleration is called 'G_Force_Lat'. Let's assume that acceleration is less than 3G in all directions. Finally, set 'unit' to {'G', 'G'} so that the data stored in 'G_Force_Long' 'G_Force_Lat'and is returned using units of 'G' and not using the SI units.

figure 												%Create a new figure for plotting
ds.Histogram2('G_Force_Lat', 'G_Force_Long',...		%Plot longitudinal vs lateral acceleration
			 [-3, 3; -3, 3], 'unit', {'G', 'G'})	%We expect acceleration to be less than 3G

Full Script

dm = Datamaster;

%Get Datasource that occurred during the competition (May 10-15th 2016)
ds = dm.getDatasource('StartDate', '2016-05-10', 'EndDate', '2016-05-15');

figure 												%Create a new figure for plotting
ds.Histogram2('G_Force_Lat', 'G_Force_Long',...		%Plot longitudinal vs lateral acceleration
			 [-3, 3; -3, 3], 'unit', {'G', 'G'});	%We expect acceleration to be less than 3G