Multiple logic outputs not working
Mostra commenti meno recenti
Hi, I'm trying to get my logical outputs of (1/0) to match up for each value of a matrix I input and it's only giving me the last result. What do I need to change to get it to save each output?
Inputs:
month =
3
3
3
day =
12
12
12
year =
2014
2014
2014
Date2 =
'2014-03-12 19:06:10'
'2014-03-12 19:06:20'
'2014-03-12 19:06:30'
Code is as follows:
if (month > 3) & (month <11)
DST=true;
elseif ((month < 3) | (month > 11))
DST= false;
elseif (month == 3)
if (day > 14)
DST=true;
elseif (day < 8)
DST=false;
else
DOW = weekday(Date2,'yyyy-mm-dd');
if (DOW == 1)
DST=true;
elseif (DOW > 1)
if ((DOW == 2) & (day > 8))
DST = true;
elseif ((DOW == 3) & (day > 9))
DST = true;
elseif ((DOW == 4) & (day > 10))
DST = true;
elseif ((DOW == 5) & (day > 11))
DST = true;
elseif ((DOW == 6) & (day > 12))
DST = true;
elseif ((DOW == 7) & (day > 13))
DST = true;
else
DST = false;
end
end
end
elseif (month == 11)
if (day > 7)
DST=false;
else
DOW = weekday(Date2,'mm/dd/yyyy');
if (DOW == 1)
DST=false;
elseif (DOW > 1)
if ((DOW == 2) & (day < 2))
DST = true;
elseif ((DOW == 3) & (day <3))
DST = true;
elseif ((DOW == 4) & (day <4))
DST = true;
elseif ((DOW == 5) & (day <5))
DST = true;
elseif ((DOW == 6) & (day <6))
DST = true;
elseif ((DOW == 7) & (day <7))
DST = true;
else
DST = false;
end
end
end
else
DST = false;
end
Also, any suggestions for improvement are welcome. I'm new to this, hence the really basic coding.
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Price and Analyze Financial Instruments in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!