How would I write this command?

조회 수: 6 (최근 30일)
Ryan Williams
Ryan Williams 2021년 3월 11일
댓글: Ryan Williams 2021년 3월 12일
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))));
Ryan Williams
Ryan Williams 2021년 3월 12일
Appreciate the help!

댓글을 달려면 로그인하십시오.

답변 (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