Info
此问题已关闭。 请重新打开它进行编辑或回答。
Hello, can somebody help me for this repeated events?
1 次查看(过去 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!