Using controlchart with specified time vector

5 ビュー (過去 30 日間)
KAE 2020 年 8 月 3 日
編集済み: KAE 2020 年 8 月 3 日
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 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 Center および File ExchangeTime Series についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by