Borrar filtros
Borrar filtros

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

2 visualizaciones (últimos 30 días)
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 comentarios
Rajesh Balagam
Rajesh Balagam el 16 de Oct. de 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.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by