Using controlchart with specified time vector

1 次查看(过去 30 天)
I have some measurements consisting of an irregularly-sampled datetime vector and measured values, and I would like to use the controlchart function to make an "individual observeration" plot of this data. How can I create the time vector that controlchart will accept? The input argument can be a time series object but I am not sure how to create one from my datetime vector. [I am also curious about the history of the time series object since the documentation for it is buried - was this a brief-lived predecessor to the datetime type?]

回答(1 个)

KAE
KAE 2020-8-3
编辑:KAE 2020-8-3
Here is what I have tried. The time labeling on the x-axis is not as nice as plots that use datetime; for my real data, it is labeled in financial quarters (!), but this can be changed.
% Create example datetime vector of measurement times
t1 = datetime(2000,1,1,1,0,0);
t2 = datetime(2001,12,31,0,0,0);
timeDatetime = t1:t2; % Format is 'dd-MMM-uuuu HH:mm:ss'
% Convert from datetime to cell array of time strings
timeForSeries = cellstr(timeDatetime);
nTime = length(timeForSeries);
% Create fake measurements which have a Gaussian distribution
% since this is what controlchart assumes
mu = 5; sigma = 7; % Mean and standard deviation of distribution
valuesForSeries = normrnd(mu,sigma,[nTime 1]);
% Make timeseries object
ts = timeseries(valuesForSeries, timeForSeries);
controlchart(ts, 'chart', 'i'); % Individual measurement

类别

Help CenterFile Exchange 中查找有关 AI for Signals 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by