Problem 1040. Create a Cell array of month-end date strings within a provided date range
This is a variation of Get an array of month-ends by T.D. where the result is now a cell array of date strings.
For example:
date_start = datenum('10 Nov 2010'); date_end = datenum('10 Feb 2011'); [dates_me{1:3}] = month_ends(date_start, date_end); dates_me dates_me = '30-Nov-2010' '31-Dec-2010' '31-Jan-2011'
The test suite uses [y{1:3}]=month_ends(d1,d2);
Is there a way to receive variable number of cells from a function call?
J.G pointed out a better Cell array implementation that does not use varargout. This revised version is Challenge 1044
Related challenge is Usage of varargout.
Solution Stats
Problem Comments
-
1 Comment
J-G van der Toorn
on 20 Nov 2012
You could just use
dates_me = month_ends(date_start, date_end);
to get a variable number of cells in the output. That avoids the user of varargout and the limitation to the number of outputs.
Solution Comments
Show commentsProblem Recent Solvers27
Suggested Problems
-
1008 Solvers
-
122 Solvers
-
Return elements unique to either input
769 Solvers
-
Arrange vector in ascending order
775 Solvers
-
184 Solvers
More from this Author308
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!