Hi I am trying to write a code that takes in a vector of doubles and return only prime numbers. I understand I can do this by using isprime() function but I want to try it wo using that function. Could you show me how to do it by using loops?

답변 (1개)

KSSV
KSSV 2020년 6월 13일

0 개 추천

If A is your array,
iwant = A(isprime(A))

댓글 수: 2

gmltn1212
gmltn1212 2020년 6월 13일
I am not trying to use isprime function!
KSSV
KSSV 2020년 6월 13일
This is discussed lot of times.....you search in mathworks google. You will get many links.

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

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

질문:

2020년 6월 13일

댓글:

2020년 6월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by