Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Correct

54Size
Leading solution size is 31.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
%%
d1 = datenum('10-Nov-2010');
d2 = datenum('10-Feb-2011');
y_correct = {'30-Nov-2010','31-Dec-2010','31-Jan-2011'};
[y{1:3}]=month_ends(d1,d2);
assert(isequal(y,y_correct))
dates =
        2010          11          10           0           0           0
        2010          11          11           0           0           0
        2010          11          12           0           0           0
        2010          11          13           0           0           0
        2010          11          14           0           0           0
        2010          11          15           0           0           0
        2010          11          16           0           0           0
        2010          11          17           0           0           0
        2010          11          18           0           0           0
        2010          11          19           0           0           0
        2010          11          20           0           0           0
        2010          11          21           0           0           0
        2010          11          22           0           0           0
        2010          11          23           0           0           0
        2010          11          24           0           0           0
        2010          11          25           0           0           0
        2010          11          26           0           0           0
        2010          11          27           0           0           0
        2010          11          28           0           0           0
        2010          11          29           0           0           0
        2010          11          30           0           0           0
        2010          12           1           0           0           0
        2010          12           2           0           0           0
        2010          12           3           0           0           0
        2010          12           4           0           0           0
        2010          12           5           0           0           0
        2010          12           6           0           0           0
        2010          12           7           0           0           0
        2010          12           8           0           0           0
        2010          12           9           0           0           0
        2010          12          10           0           0           0
        2010          12          11           0           0           0
        2010          12          12           0           0           0
        2010          12          13           0           0           0
        2010          12          14           0           0           0
        2010          12          15           0           0           0
        2010          12          16           0           0           0
        2010          12          17           0           0           0
        2010          12          18           0           0           0
        2010          12          19           0           0           0
        2010          12          20           0           0           0
        2010          12          21           0           0           0
        2010          12          22           0           0           0
        2010          12          23           0           0           0
        2010          12          24           0           0           0
        2010          12          25           0           0           0
        2010          12          26           0           0           0
        2010          12          27           0           0           0
        2010          12          28           0           0           0
        2010          12          29           0           0           0
        2010          12          30           0           0           0
        2010          12          31           0           0           0
        2011           1           1           0           0           0
        2011           1           2           0           0           0
        2011           1           3           0           0           0
        2011           1           4           0           0           0
        2011           1           5           0           0           0
        2011           1           6           0           0           0
        2011           1           7           0           0           0
        2011           1           8           0           0           0
        2011           1           9           0           0           0
        2011           1          10           0           0           0
        2011           1          11           0           0           0
        2011           1          12           0           0           0
        2011           1          13           0           0           0
        2011           1          14           0           0           0
        2011           1          15           0           0           0
        2011           1          16           0           0           0
        2011           1          17           0           0           0
        2011           1          18           0           0           0
        2011           1          19           0           0           0
        2011           1          20           0           0           0
        2011           1          21           0           0           0
        2011           1          22           0           0           0
        2011           1          23           0           0           0
        2011           1          24           0           0           0
        2011           1          25           0           0           0
        2011           1          26           0           0           0
        2011           1          27           0           0           0
        2011           1          28           0           0           0
        2011           1          29           0           0           0
        2011           1          30           0           0           0
        2011           1          31           0           0           0
        2011           2           1           0           0           0
        2011           2           2           0           0           0
        2011           2           3           0           0           0
        2011           2           4           0           0           0
        2011           2           5           0           0           0
        2011           2           6           0           0           0
        2011           2           7           0           0           0
        2011           2           8           0           0           0
        2011           2           9           0           0           0
        2011           2          10           0           0           0
new_month =
        2010          11          30           0           0           0
        2010          12          31           0           0           0
        2011           1          31           0           0           0
strArray =
    '30-Nov-2010'
strArray =
    '30-Nov-2010'    '31-Dec-2010'
strArray =
    '30-Nov-2010'    '31-Dec-2010'    '31-Jan-2011'
varargout =
    '30-Nov-2010'    '31-Dec-2010'    '31-Jan-2011'
2
Pass
 
%%
d1 = datenum('31-Jan-2000');
d2 = datenum('10-Apr-2000');
y_correct = {'31-Jan-2000','29-Feb-2000','31-Mar-2000'};
[y{1:3}]=month_ends(d1,d2);
assert(isequal(y,y_correct))
dates =
        2000           1          31           0           0           0
        2000           2           1           0           0           0
        2000           2           2           0           0           0
        2000           2           3           0           0           0
        2000           2           4           0           0           0
        2000           2           5           0           0           0
        2000           2           6           0           0           0
        2000           2           7           0           0           0
        2000           2           8           0           0           0
        2000           2           9           0           0           0
        2000           2          10           0           0           0
        2000           2          11           0           0           0
        2000           2          12           0           0           0
        2000           2          13           0           0           0
        2000           2          14           0           0           0
        2000           2          15           0           0           0
        2000           2          16           0           0           0
        2000           2          17           0           0           0
        2000           2          18           0           0           0
        2000           2          19           0           0           0
        2000           2          20           0           0           0
        2000           2          21           0           0           0
        2000           2          22           0           0           0
        2000           2          23           0           0           0
        2000           2          24           0           0           0
        2000           2          25           0           0           0
        2000           2          26           0           0           0
        2000           2          27           0           0           0
        2000           2          28           0           0           0
        2000           2          29           0           0           0
        2000           3           1           0           0           0
        2000           3           2           0           0           0
        2000           3           3           0           0           0
        2000           3           4           0           0           0
        2000           3           5           0           0           0
        2000           3           6           0           0           0
        2000           3           7           0           0           0
        2000           3           8           0           0           0
        2000           3           9           0           0           0
        2000           3          10           0           0           0
        2000           3          11           0           0           0
        2000           3          12           0           0           0
        2000           3          13           0           0           0
        2000           3          14           0           0           0
        2000           3          15           0           0           0
        2000           3          16           0           0           0
        2000           3          17           0           0           0
        2000           3          18           0           0           0
        2000           3          19           0           0           0
        2000           3          20           0           0           0
        2000           3          21           0           0           0
        2000           3          22           0           0           0
        2000           3          23           0           0           0
        2000           3          24           0           0           0
        2000           3          25           0           0           0
        2000           3          26           0           0           0
        2000           3          27           0           0           0
        2000           3          28           0           0           0
        2000           3          29           0           0           0
        2000           3          30           0           0           0
        2000           3          31           0           0           0
        2000           4           1           0           0           0
        2000           4           2           0           0           0
        2000           4           3           0           0           0
        2000           4           4           0           0           0
        2000           4           5           0           0           0
        2000           4           6           0           0           0
        2000           4           7           0           0           0
        2000           4           8           0           0           0
        2000           4           9           0           0           0
        2000           4          10           0           0           0
new_month =
        2000           1          31           0           0           0
        2000           2          29           0           0           0
        2000           3          31           0           0           0
strArray =
    '31-Jan-2000'
strArray =
    '31-Jan-2000'    '29-Feb-2000'
strArray =
    '31-Jan-2000'    '29-Feb-2000'    '31-Mar-2000'
varargout =
    '31-Jan-2000'    '29-Feb-2000'    '31-Mar-2000'