Plot: dealing with data available only on weekdays

I want to plot X (date), Y, and Z. Y has an entry for every day but Z has entry only for weekdays (not weekends). Will the code
plot(X,Y)
hold on
plot(X,smooth(Z))
will give us the smooth (that is, no gaps for Z) graphs? What will be the best way to deal with these data?

3 件のコメント

dpb
dpb 2018 年 6 月 10 日
How do you want to deal with it? Does it make any sense to interpolate for Z? If were market closing values, say, there simply is no data; making something up would be nonsensical.
Filling wit NaN for missing values will automagically not show those values on a plot; if use a datetime for datenum value for X then the time axis will be real time; there isn't a ready-built function in Matlab that will "squish out" weekends if that's the desire.
alpedhuez
alpedhuez 2018 年 6 月 11 日
What are the options?
dpb
dpb 2018 年 6 月 11 日
You have a general purpose programming language in front of you; you can drive it however desired. The problem is to define what it is you really want in order to implement it.
At least a few of the options would be to
  1. ignore weekends entirely
  2. use real time and plot data where they fall
  3. use real time and missing values for weekends
  4. use real time and interpolate data for missing values
It all depends on what the data represent and what you want to try to depict...

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

回答 (1 件)

per isakson
per isakson 2018 年 6 月 11 日
編集済み: per isakson 2018 年 6 月 11 日

0 投票

I assume
  • X and Y have the same length
  • Z is shorter than X
  • Y and Z hold one value per day
  • the length of X is less than 120
Am I right so far?
I would
  • depict the values with markers, rather than lines, e.g. Square and Diamond, respectively
  • not show anything for Z for weekends

2 件のコメント

alpedhuez
alpedhuez 2018 年 6 月 11 日
1-3 are correct. X can be potentially much larger than 120.
per isakson
per isakson 2018 年 6 月 11 日
編集済み: per isakson 2018 年 6 月 11 日
  • How do you synchronize Z with Y? How do you know which Z-value belong to which weekday?

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

カテゴリ

製品

タグ

質問済み:

2018 年 6 月 10 日

コメント済み:

dpb
2018 年 6 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by