Info
This question is closed. Reopen it to edit or answer.
Hello, can somebody help me for this repeated events?
2 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Image Analyst
on 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 Comment
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!