Using controlchart with specified time vector

조회 수: 2 (최근 30일)
KAE
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
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에서 Preprocessing Data에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by