Clear Filters
Clear Filters

How to not overwrite answers

5 views (last 30 days)
Pas182
Pas182 on 10 Jun 2022
Commented: Mathieu NOE on 13 Jun 2022
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 Comments
Pas182
Pas182 on 10 Jun 2022
it's exactly what i was trying to do. Thank you so much!!

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!