Trying to change plot style

4 ビュー (過去 30 日間)
Nathaniel Porter
Nathaniel Porter 2021 年 12 月 19 日
コメント済み: Star Strider 2021 年 12 月 19 日
%Plot of entire patient one time series
load ('glucose.mat')
glucose_mgdl = glucose * 18;
plot(date1+time,glucose_mgdl),
xlabel('Days'), ylabel('Glucose')
title('Glucose readings vs days/time')
M = mean(glucose_mgdl)
M = 183.4936
S = std(glucose_mgdl)
S = 87.6448
Trying to display correlogram as the picture seen below what do I have to add to my code:
%Plot of correlogram
[r,lags] = xcorr(glucose_mgdl,'coeff');
figure
plot(lags, r, '.')
grid
xlabel('Lags')
ylabel('Croorelation Coefficient')
title('Autocorrelation')

採用された回答

Star Strider
Star Strider 2021 年 12 月 19 日
Trying to display correlogram as the picture seen below what do I have to add to my code:
The plot in the documentation is a stem plot. I plotted that originally, however the data are so densely packed that it simply appears as a filled area below the curve (even when using '.' as the marker).
One option would be to select a subset of values and plot them —
%Plot of entire patient one time series
T1 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/838945/glucose.csv');
glucose = T1.glucose;
date_time = T1.date + T1.time;
glucose_mgdl = glucose * 18;
plot(date_time,glucose_mgdl),
xlabel('Days'), ylabel('Glucose')
title('Glucose readings vs days/time')
M = mean(glucose_mgdl)
M = 183.4936
S = std(glucose_mgdl)
S = 87.6448
%Plot of correlogram
[r,lags] = xcorr(glucose_mgdl,'coeff');
sampstep = 10; % Sampling Step
rs = r(1:sampstep:end);
lagss = lags(1:sampstep:end);
figure
stem(lagss, rs, '.')
grid
xlabel('Lags')
ylabel('Crorelation Coefficient')
title('Autocorrelation')
Change the value of ‘sampstep’ to get different stem plot results.
.
  2 件のコメント
Nathaniel Porter
Nathaniel Porter 2021 年 12 月 19 日
Oh okay thank you
Star Strider
Star Strider 2021 年 12 月 19 日
As always, my pleasure!
.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

タグ

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by