How to not overwrite answers

5 次查看(过去 30 天)
Pas182
Pas182 2022-6-10
Hi,
in a for cycle i have the issue for that the answer to a command are overwritten. Below the code which i'm facing with:
for i=1:length(Lamp_config)
st1(i)=(strcmp(Lamp_config(i),h));
st2(i)=(strcmp(Lamp_config(i),o));
st3(i)=(strcmp(Lamp_config(i),l));
st4(i)=(strcmp(Lamp_config(i),m));
if st2(i)==1
o1=ismember(0,NaDFIR_from_tool(i,:));
o2=ismember(39,NaDFIR_from_tool(i,:));
o3=ismember(175,NaDFIR_from_tool(i,:));
o4=ismember(174,NaDFIR_from_tool(i,:));
o5=ismember(172,NaDFIR_from_tool(i,:));
o6=ismember(168,NaDFIR_from_tool(i,:));
o7=ismember(40,NaDFIR_from_tool(i,:));
if o1 == 1
'DTC enabled'
else
'DTC not enabled'
end
if o2 == 1
'1 trip failed'
else
'1 trip NOT failed'
end
if o3 == 1
'2 trip failed'
else
'2 trip NOT failed'
end
if o4 == 1
'3 trip failed'
else
'3 trip NOT failed'
end
if o5 == 1
'fault passing'
else
'fault NOT passing'
end
if o6 == 1
'1 trip healing'
else
'1 trip NOT healing'
end
if o7 == 1
'2 trip healing'
else
'2 trip NOT healing'
end
end
So in this way the "ans" is continuesly overwritten (DTC enabled --> 1 trip failed --> 2 trip failed and so...). My target is to save all the ans i get in a matrix.
How can I do it?
Thank you so much!
  3 个评论
Pas182
Pas182 2022-6-10
it's exactly what i was trying to do. Thank you so much!!

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by