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

1 vue (au cours des 30 derniers jours)
Meowooo
Meowooo le 13 Oct 2017
Commenté : Walter Roberson le 16 Oct 2017
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.
  2 commentaires
Rajesh Balagam
Rajesh Balagam le 16 Oct 2017
Please rephrase your question specifying the location of the issue. Also explain the problem you are trying to solve and how you are approaching it.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by