Info
この質問は閉じられています。 編集または回答するには再度開いてください。
Hello, can somebody help me for this repeated events?
2 ビュー (過去 30 日間)
古いコメントを表示
A= 0 0 1 1 0 1 1 1 0 0 0 1 1 1 0 1 1 1 0 1 0 1 1 1 1
if there is '0' should print 'UNAVAILABLE'
if there is '1' less than 3 unit should print 'BAD'
if there is '1' equal to 3 unit should print 'AVERAGE'
if there is '1' more than 3 unit should print 'GOOD'
So, based on above situation the answer should be:
UNAVAILABLE
BAD
UNAVAILABLE
AVERAGE
UNAVAILABLE
AVERAGE
UNAVAILABLE
AVERAGE
UNAVAILABLE
BAD
UNAVAILABLE
GOOD
0 件のコメント
回答 (1 件)
Image Analyst
2015 年 2 月 22 日
This is just a simple for loop using if and fprintf(). See this http://www.mathworks.com/matlabcentral/answers/8026-best-way-s-to-master-matlab. I don't really know what "if there is '1' less than 3 unit" means. Your A has only values of 0 and 1 so everything is less than 3. And what does "unit" mean??? Anyway, here's some pseudocode to get you started
for k = 1 : length(A)
if A(k) == 0
fprintf('UNAVAILABLE\n');
elseif A(k) < 1 % or 3 -- whichever you mean.
fprintf('BAD\n');
elseif A(k.............etc.
end
end
1 件のコメント
この質問は閉じられています。
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!