How would I write this command?

8 次查看(过去 30 天)
Ryan Williams
Ryan Williams 2021-3-11
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 个评论
David Hill
David Hill 2021-3-11
primes cannot be negative by my definition, but if you wanted to ignore the negative, then
max(A(isprime(abs(A))));

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by