counter odd numbers in 'randi'?

1 次查看(过去 30 天)
counter of odd numbers in 'randi'?
this is program:
a=randi([0 27],1,50);
b=zeros(1,numel(a)*3+numel(a));
b(4:4:end)=a(:)
what is need write after that?

采纳的回答

Image Analyst
Image Analyst 2018-12-2
Try this:
a=randi([0 27],1,50)
numberOfOddNumbers = sum(rem(a, 2))

更多回答(1 个)

madhan ravi
madhan ravi 2018-12-2
编辑:madhan ravi 2018-12-2
a=randi([0 27],1,50);
b=zeros(1,numel(a)*3+numel(a));
b(4:4:end)=a;
b(rem(b,2)~=0 & ~isprime(b))

类别

Help CenterFile Exchange 中查找有关 Verification, Validation, and Test 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by