Plot Excel Time Series in Matlab

2 views (last 30 days)
Hi,
I have a seemingly easy Problem. Attached is a workspace (see ws_test.mat) with two vectors (VarNames1=Dates and VarNames2=Prices). Dates are just businessdays (no Saturdays and Sundays). Creating a chart in Excel from these data was quite easy.
Now I wonder how it is possible to create a chart with monthly dates on the x-axis in Matlab. And further, whether there is an easy possibility to convert daily data in monthly data, where the relevant date is the last day of a month.
Many thanks in advance!
Kind Regards, Alex
  3 Comments
alexander
alexander on 13 Jul 2014
Hi, many thanks for letting me know. Now it should be there.
Kind Regards, Alex
alexander
alexander on 15 Jul 2014
Hi many thanks for your reply. I have found the Problem: All the time I was using timeseries, but it is much easier with the financial Toolbox. There is a command fints to define financial timeseries. With datetick it is then easy to make the appropriate adjustments.
Thanks & Kind Regards, Alex

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 13 Jul 2014
  1. No .mat file attached.
  2. Monthly dates are easy with the datetick function.
  3. How do you want ‘to convert daily data in monthly data’? Minimum, maximum, median, mean, mean ± standard error, high-low-close, ... ?
  2 Comments
alexander
alexander on 15 Jul 2014
Many thanks for your reply. The datetick advice was very helpful!
all the best, Alex

Sign in to comment.

More Answers (1)

dpb
dpb on 13 Jul 2014
Edited: dpb on 13 Jul 2014
It's only slightly more of a problem in Matlab. What you need, specifically, is slightly dependent upon the format of the date column but the deal is to convert those dates to Matlab datenum 's and plot against those. Then use datetick to display the axis in time units. This is what Excel does just a little more is hidden behind the magic curtain...
doc datenum
doc datetick
for details. There's a current thread I've demonstrated on the usenet newsgroup besides the examples in the documentation that might be of interest/help at...
As for the end-of-month, that also is pretty simple and approachable in one of several ways, the simplest probably being to compute the year,month,day vectors from the data and locate the positions where the month changes ( diff is good for such jobs) as unless it's in a financial toolbox or somesuch Matlab doesn't have a builtin function to return the last workday in a month.
help timefun
will give you the various time-manipulation functions in base Matlab; what else is in whatever Toolboxes you have installed will be in their documentation. I don't have any of the financial/business related stuff so I'm not familiar with what those might be, if any...
ADDENDUM
Seeing as how you included the Financial Toolbox in the product, I checked and indeed as one would expect there is the function lbusdate
With that simply select the values that match those returned by it over the time of interest.
There's also the financial time series object that you can create that has its own methods and plotting functions you should probably investigate; one would presume they've been designed to make such manipulations simpler than with base Matlab graphics given the nature of financial data--not much sense in the Toolbox if not.
  1 Comment
alexander
alexander on 15 Jul 2014
Hi, as written above, many thanks for your support. It was really helpful. Unfortunately clicked the accept answer button already before, for the advice to use datetick. Hope it is ok.
Thanks & Kind Regards, Alex

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!