I need help generating a code that does the following
For and if Generate an array of 10 random numbers between 1 and 100. Then find out how many of the elements are between 1 and 25, how many between 25 and 75 and how many between 75 and 100.

댓글 수: 1

Thorsten
Thorsten 2016년 9월 8일
This it homework. What have you tried to solve it?

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

답변 (1개)

s.p4m
s.p4m 2016년 9월 9일
편집: s.p4m 2016년 9월 15일

0 개 추천

small = 0;
big = 0;
mid = 0;
test = random('Normal',1,100,1,10);
for k = 1:length(test)
if ( test(k) < 25 )
small = small + 1;
elseif ( test(k) > 75 )
big = big + 1;
else
mid = mid + 1;
end
end

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

질문:

2016년 9월 8일

편집:

2016년 9월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by