How to identify date numbers corresponding to non-business days and replace them with by the next av


I am working with time series data in MATLAB. I have got two vectors of date numbers, one of which relies on a somewhat subjective data source. If both vectors were perfectly accurate, all date numbers should correspond to trading days while one vector would be a 'proper subset' of the other. Unfortunately this is not the case because one of the vectors contains several date numbers which correspond to non-business days. I would like to find a way to replace all non-business days in this vector with the next available business day.


datenumbers = [736062;736063;736064;736065;736066;736067] % corresponds to [wed, thu, fri, sat, sun, mon]

This contains [736065;736066] which corresponds to the upcoming weekend. Because these are not working days I would like to identify the date number corresponding to the subsequent monday and change both entries so that:

datenumbers = [736062;736063;736064;736067;736067;736067] % corresponds to [wed, thu, fri, mon, mon, mon]


One way to do it is simply to loop through all your values and change them if they are Saturday or Sunday.

datenumbers = [736062;736063;736064;736065;736066;736067]; for i = 1:length(datenumbers) weekDay = mod(datenumbers(i),7); if weekDay == 1 || weekDay == 2 datenumbers(i) = (3-weekDay) + datenumbers(i); end end


  • RSelenium cannot access DOM
  • quantstrat: how to execute on the same bar? [closed]
  • Advantages of only advertising data vs connecting BLE devices
  • MySQL: Optimizing Searches with LIKE or FULLTEXT
  • calculate daily averages for 3d array
  • Finding references in Visual Studio
  • Swift - pruning elements from an Array, converting integer strings to integers
  • How to transform Byte[](decoded as PNG or JPG) to Tensorflows Tensor
  • Find unique tuples in a relation represented by a BDD
  • MySql - get days remaining
  • python - calculate orthographic similarity between words of a list
  • Returning this from a constructor function in JS
  • Geom_jitter colour based on values
  • Javascript focus remove text highlight
  • runtime-check whether an instance (Base*) override a parent function (Base::f())
  • What is the use of a session store?
  • How to get the date of next specified day of week
  • How can I get the full list of running processes on a Mac from a python app
  • Is there a package like bigmemory in R that can deal with large list objects?
  • XSLT foreach repeating nodes to flat
  • Wrong labels when plotting a time series pandas dataframe with matplotlib
  • How to explicitly/implicitly implemented interface members in C++/CLI?
  • How to access culture data in globalize.js V1.0.0
  • SAXReader not re-ecape characters
  • How to determine if there are bytes available to be read from boost:asio:serial_port
  • Date Conversion from yyyy-mm-dd to dd-mm-yyyy
  • print() is showing quotation marks in results
  • Checking free space on FTP server
  • Initializer list vs. initialization method
  • Javascript Callbacks with Object constructor
  • R: gsub and capture
  • AT Commands to Send SMS not working in Windows 8.1
  • Proper folder structure for lots of source files
  • Acquiring multiple attributes from .xml file in c#
  • embed rChart in Markdown
  • How can I remove ASP.NET Designer.cs files?
  • python draw pie shapes with colour filled
  • Is there any way to bind data to data.frame by some index?
  • How can i traverse a binary tree from right to left in java?
  • How can I use `wmic` in a Windows PE script?