フィルターのクリア

change row when compiling an array

4 ビュー (過去 30 日間)
Pas182
Pas182 2022 年 6 月 10 日
コメント済み: Pas182 2022 年 6 月 14 日
Hi everyone!
with a for loop i'm compiling an array based on the answer that i get from the script.
count(i)=0;
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
count(i)=count(i)+1;
answer{count(i)} ='DTC_enabled'
else
count(i)=count(i)+1;
answer{count(i)} ='DTC_not_enabled'
end
if o2 == 1
count(i)=count(i)+1;
answer{count(i)} ='1_trip_failed'
else
count(i)=count(i)+1;
answer{count(i)} ='1_trip_NOT_failed'
end
if o3 == 1
count(i)=count(i)+1;
answer{count(i)} ='2 trip failed'
else
count(i)=count(i)+1;
answer{count(i)} ='2 trip NOT failed'
end
if o4 == 1
count(i)=count(i)+1;
answer{count(i)} ='3 trip failed'
else
count(i)=count(i)+1;
answer{count(i)} ='3 trip NOT failed'
end
if o5 == 1
count(i)=count(i)+1;
answer{count(i)} ='fault passing'
else
count(i)=count(i)+1;
answer{count(i)} ='fault NOT passing'
end
if o6 == 1
count(i)=count(i)+1;
answer{count(i)} ='1 trip healing'
else
count(i)=count(i)+1;
answer{count(i)} ='1 trip NOT healing'
end
if o7 == 1
count(i)=count(i)+1;
answer{count(i)} ='2 trip healing'
else
count(i)=count(i)+1;
answer{count(i)} ='2 trip NOT healing'
end
end
The issue is that at the next i, the answer array will be overwritten. My target is that at the next i the array begins to be compilated in the second row.
So how can i switch row array when the i changes?
thank you so much!
  1 件のコメント
Jan
Jan 2022 年 6 月 10 日
編集済み: Jan 2022 年 6 月 10 日
What does "compilated in the 2nd row" mean? Do you mean concatenated?
Hints:
  • strcmp replies a logical already. There is no need to compare it with 1:
st1(i) = strcmp(Lamp_config(i), h);
if st2(i) % without == 1
o1 = ismember(0, NaDFIR_from_tool(i,:));
% Faster: o1 = any(NaDFIR_from_tool(i,:) == 0)
if o1 % without == 1
...
end
end

サインインしてコメントする。

採用された回答

Jan
Jan 2022 年 6 月 10 日
Pool = {'DTC_enabled', 'DTC_not_enabled'; ...
'1_trip_failed', '1_trip_NOT_failed'; ...
'2 trip failed', '2 trip NOT failed'; ...
'3 trip failed', '3 trip NOT failed'; ...
'fault passing', 'fault NOT passing'; ...
'1 trip healing', '1 trip NOT healing'; ...
'2 trip healing', '2 trip NOT healing'};
asnwer = {};
for i = 1:length(Lamp_config)
st1(i) = strcmp(Lamp_config(i), h);
if st2(i)
match = ismember([0; 39; 175; 174; 172; 168; 40], NaDFIR_from_tool(i,:));
answer = [answer, Pool(:, match + 1)];
end
end
I'm not sure, if this matchs your needs, because I do not understand the term "compile" here. But maybe this simplified versions is much easier to adjust to your needs.
  1 件のコメント
Pas182
Pas182 2022 年 6 月 14 日
Thank you so much!

サインインしてコメントする。

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2022 年 6 月 10 日
Store into answer{i}

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by