Clear Filters
Clear Filters

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

2 views (last 30 days)
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.

Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!