How do i extract only prime numbers from a matrix

3 ビュー (過去 30 日間)
Vc27
Vc27 2022 年 11 月 18 日
コメント済み: Vc27 2022 年 11 月 18 日
I have a row vector with 100 variables and i want to extract all the prime numbers in this, is there a simple way to do this? thanks in advance

採用された回答

Stephen23
Stephen23 2022 年 11 月 18 日
V = randi(1000,1,100) % fake data
V = 1×100
920 211 723 2 758 106 665 423 252 67 473 947 500 168 294 520 667 139 896 372 309 631 401 721 922 302 799 428 496 743
P = V(isprime(V)) % the prime values
P = 1×14
211 2 67 947 139 631 401 743 53 181 47 521 449 71
  1 件のコメント
Vc27
Vc27 2022 年 11 月 18 日
Great thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNetworks についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by