How would I write this command?
Ältere Kommentare anzeigen
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 Kommentare
the cyclist
am 11 Mär. 2021
This seems like homework. If you show us what you have tried so far, and ask a specific question, we can give you a hint. That is a good way to learn.
If you have no idea at all on how to get started, I suggest asking your instructor for help.
David Hill
am 11 Mär. 2021
primes cannot be negative by my definition, but if you wanted to ignore the negative, then
max(A(isprime(abs(A))));
Ryan Williams
am 12 Mär. 2021
Antworten (0)
Kategorien
Mehr zu Logical finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!