Error in displaying output

8 ビュー (過去 30 日間)
FIR
FIR 2011 年 11 月 3 日
I have posted code below
A=[1;2;3;4;0;0;0;0]
for i=1:size(A)
if A(i)==0
A1= 'good'
else
A1= 'bad'
end
end
the output i get is
A1=bad
A1=bad
;
;
;
;
;A1=good
but i need to be dispalyed as
bad
bad
;
;
;
good
i know it is simple ,i tried but could not get the answer..plase help

採用された回答

Grzegorz Knor
Grzegorz Knor 2011 年 11 月 3 日
A=[1;2;3;4;0;0;0;0];
for i=1:size(A)
if A(i)==0
A1= 'good';
else
A1= 'bad';
end
disp(A1)
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeEngines & Motors についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by