How to count how many numbers are prime in each column

I have a 100x10 matrix that goes from 1-1000 , and each set of hundreds is in its own column.
onethousand = reshape(1:1000, 100, 10)
I need to find how many prime numbers are in each column. I know that I have to use the function isprime, but I do not know how. Any suggestions?

Answers (1)

How about using isprime function?
sum(isprime(onethousand))
It returns:
>> sum(isprime(onethousand))
ans =
25 21 16 16 17 14 16 14 15 14

Categories

Tags

Asked:

on 22 Apr 2018

Answered:

on 22 Apr 2018

Community Treasure Hunt

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

Start Hunting!