For loop question, switch loop question, don't know how to incorporate them together

2 次查看(过去 30 天)
function [ vowels ] = findVowels( charCell )
string st = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
a = st[Random.Range(st.Length)];
charCell = {a1, a2; a3, a4};
switch vowles(letter)
case {'a' 'e''i''o''u'}
a = {'letter1','letter2';'letter3','letter4'};
otherwise
disp a = []
end
My answer:
function [ doy ] = calcDayOfYear( day, month, year )
% Day, month and year are integers corresponding to a given date
%and day is that date's of the year
if doy = numDays*month
if year = 'a leap year';
if year./400 = 2n;
disp('a leap year');
elseif (year./100 = 2n;
disp('not a leap year');
elseif year./4 = 2n;
disp('a leap year');
else
disp('not a leap year');
end
numDays = 29;
else
numDays = 28;
end
switch lower(month)
case {1 3 5 7 8 10 12}
numDays = 31;
case {4 6 9 11}
numDays = 30;
case {2}
if year = [a leap year];
numDays = 29;
otherwise
numDays = 28;
end
Totally have no idea how to incorporate them together, it is such a mess for my code too
Thanks a lot for whoever is answering my question.

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by