Azzera filtri
Azzera filtri

Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

Hello, can somebody help me for this repeated events?

2 visualizzazioni (ultimi 30 giorni)
khoo chai
khoo chai il 22 Feb 2015
Chiuso: MATLAB Answer Bot il 20 Ago 2021
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

Risposte (1)

Image Analyst
Image Analyst il 22 Feb 2015
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 Commento
khoo chai
khoo chai il 22 Feb 2015
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'

Questa domanda è chiusa.

Community Treasure Hunt

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

Start Hunting!

Translated by