How would I write this command?

8 vues (au cours des 30 derniers jours)
Ryan Williams
Ryan Williams le 11 Mar 2021
Commenté : Ryan Williams le 12 Mar 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 commentaires
David Hill
David Hill le 11 Mar 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 le 12 Mar 2021
Appreciate the help!

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by