How would I write this command?

6 visualizaciones (últimos 30 días)
Ryan Williams
Ryan Williams el 11 de Mzo. de 2021
Comentada: Ryan Williams el 12 de Mzo. de 2021
Write MATLAB commands that computes the maximum prime number in a matrix.
I tried
function MaxPrime = MaxPrime(A)
MaxPrime = max(isprime(A));
disp(MaxPrime)
end
got an error because one of my integers was negative. please help
  3 comentarios
David Hill
David Hill el 11 de Mzo. de 2021
primes cannot be negative by my definition, but if you wanted to ignore the negative, then
max(A(isprime(abs(A))));
Ryan Williams
Ryan Williams el 12 de Mzo. de 2021
Appreciate the help!

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by