How would I write this command?
8 views (last 30 days)
Show older comments
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 Comments
David Hill
on 11 Mar 2021
primes cannot be negative by my definition, but if you wanted to ignore the negative, then
max(A(isprime(abs(A))));
Answers (0)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!