Going from a Matrix of months to a date.
15 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Days_into_Month = cell(n,1);
Month = char(Month(1:n,1));
for d = (1:n)'
switch Month(d,1)
case {'Jan'}
Days_into_Month(d,1) = {Total_Days(d,1) +6};
case {'Feb'}
Days_into_Month(d,1) = {Total_Days(d,1) - 24};
case {'Mar'}
Days_into_Month(d,1) = {Total_Days(d,1) - 53};
case {'Apr'}
Days_into_Month(d,1) = {Total_Days(d,1) - 84};
case {'May'}
Days_into_Month(d,1) = {Total_Days(d,1) - 114};
case {'Jun'}
Days_into_Month(d,1) = {Total_Days(d,1) - 145};
case {'Jul'}
Days_into_Month(d,1) = {Total_Days(d,1) - 175};
case {'Aug'}
Days_into_Month(d,1) = {Total_Days(d,1) - 206};
case {'Sep'}
Days_into_Month(d,1) = {Total_Days(d,1) - 237};
case {'Oct'}
Days_into_Month(d,1) = {Total_Days(d,1) - 267};
case {'Nov'}
Days_into_Month(d,1) = {Total_Days(d,1) - 298};
case {'Dec'}
Days_into_Month(d,1) = {Total_Days(d,1) - 328};
case {'Ja_'}
Days_into_Month(d,1) = {Total_Days(d,1) - 359};
Actual_Year = Actual_Year + 1;
end
end
I am looking for my matrix to come back with different numbers varying to each month.
Month =
'Mar'
'Dec'
'Oct'
'Oct'
'May'
'Jul'
'Dec'
This is the current month data set that I have and i need Days_into_Month to be a result of Total_Days(d,1) subtract the corresponding number.
0 Kommentare
Antworten (1)
Walter Roberson
am 18 Okt. 2015
dayoff = [6, -24, -53, -84, .... -359];
[tf, monidx] = ismember(Month, {'Jan', 'Feb', 'Mar', .... 'Dec', 'Ja_'});
Days_into_Month = Today_days + dayoff(monidx);
0 Kommentare
Siehe auch
Kategorien
Mehr zu Interpolation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!