– Generate a vector of 20 random integers, each in the range from 50 to 100. Create a variable evens that stores all of the even numbers from the vector and a variable odds that stores the odd numbers.
6 ビュー (過去 30 日間)
古いコメントを表示
Can someone please help me solve this problem? I haven't learn about (mod) yet! so please if you can provide me another way to do that will be helpful. Thanks
1 件のコメント
Korede Akinpelumi
2017 年 5 月 16 日
編集済み: Walter Roberson
2017 年 5 月 16 日
function [evens,odds]=assignm
A=randi(51,1,20)+49;
B=50:2:100;
C=51:2:99;
evens=intersect(A,B);
odds=intersect(A,C);
end
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!