Non-functioning function
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Jacob Smith
el 27 de Feb. de 2021
Editada: Jacob Smith
el 27 de Feb. de 2021
function output = calculateFactorial(N)
output = N*(N-1);
if (length(N) = N < 1 || N > 1)
output = 'Error; N must be a single number and not an array';
elseif N < 0
output = 'Error; N must be greater than Zero';
elseif rem(N,1) ~= 0
output = 'Error; Intger must be whole number';
elseif N == 0
output = 1;
end
struggling with these functions. If i ommit line 2, theres then a mistake on line 3 where there is an incoorrect use of '='. I need help wrapping my head around my mistakes.
0 comentarios
Respuesta aceptada
madhan ravi
el 27 de Feb. de 2021
if length(N) > 1
3 comentarios
madhan ravi
el 27 de Feb. de 2021
Editada: madhan ravi
el 27 de Feb. de 2021
output = calculateFactorial(1.1)
output = calculateFactorial(-1 : 3)
output = calculateFactorial(-1)
output = calculateFactorial(3)
function output = calculateFactorial(N)
output = N .* (N-1);
if length(N) > 1
output = 'Error; N must be a single number and not an array';
elseif N < 0
output = 'Error; N must be greater than Zero';
elseif rem(N,1) ~= 0
output = 'Error; Intger must be whole number';
elseif N == 0
output = 1;
end
end
Más respuestas (0)
Ver también
Categorías
Más información sobre Pulsed Waveforms 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!