フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Hello, can somebody help me for this repeated events?

2 ビュー (過去 30 日間)
khoo chai
khoo chai 2015 年 2 月 22 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
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

回答 (1 件)

Image Analyst
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 件のコメント
khoo chai
khoo chai 2015 年 2 月 22 日
TQ sir for your concerned,
Actually 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]
So that when generate, 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
What I mean was based on A>>>
when any '0' it will print 'UNAVAILABLE'
when '1' is repeated less than 3 times it will print 'BAD'
when '1' is repeated equal to 3 times it will print 'AVERAGE'
when '1' is repeated more than 3 times it will print 'GOOD'

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by