How to create a new array with variables that did not meet the required parameters.

1 view (last 30 days)
My code is written so that it displays whether or not a certain batch has failed or not. However, I would like it to seperate the failed batches into a new (vertical) array and the good batches into a second (vertical) array, without fprinting whether or not it is a good batch or a failed batch. I need this new array in order to calculate the percent that failed.
for idx = 1:numel(arrayDwellTime);
element = arrayDwellTime(idx);
....;
end
count=1;
while count<length(arrayDwellTime);
DwellTime=arrayDwellTime(count,1);
count=count+1;
for k = 1:length(DwellTime);
fprintf('%i',DwellTime(k));
end
if DwellTime>=2 && DwellTime<=2.5 fprintf(' batch good \n')
else fprintf(' batch failed \n')
end
end

Answers (1)

darova
darova on 6 Oct 2019
Try
cond = DwellTime>=2 & DwellTime<=2.5;
[cond.*DwellTime ~cond.*DwellTime]

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!