Trying to pull intermittent errors from an array
조회 수: 1 (최근 30일)
이전 댓글 표시
Within column 8 in each Table_A there are intermittent values of 1, i need to pull the all of the columns of the rows where column 8 is equal to one in each run as they represent a data error in a previous loop that needs to be accounted for in each value of i, these errors should not be more than 200.
I was thinking I could some how fill a zero array with as many rows as neccesary and then leave the rest as zeros?
num = 16; %Number that needs to remain changeable
goal = 10000; %Number that needs to remain changeable
Array_A = rand(goal*num,9); %Is built in a previous loop
Errors = zeros(200,num); %Place holder?
for i = 1:num
Array_AB = Array_A(i:num:end,:);
Array_AC = Array_AB(any(Array_AB(:,5:7),2),:);
Table_A = array2table(Array_AC);
Table_AB = sortrows(Table_A,[2 3],"descend")
Errors(:,i) = Array_AC((Array_AC(:,8)==1),:) %Returns an error because dimensions don't match
end
Or perhaps pull the rows i want an pad them?
num = 16 %Number that needs to remain changeable
goal = 10000 %Number that needs to remain changeable
Array_A = randi(goal*num,9) %Is built in a previous loop
Errors = zeros(200,num) %Place holder?
for i = 1:num
Array_A = A(i:num:end,:);
Array_A = Array_A(any(Array_A(:.5:7),2),:);
Table_A = array2table(Array_A);
Table_A = sortrows(Table_A,[2 3],"descend")
Pull = Array_A((Array_A(:,8)==1),:)
%some magick that turns this into a 200x8 matrix padded with zeros
Errors(:,i) = Pull
end
Eventually I need Errors to contain the entire row of the runs that contained errors for further analysis.
댓글 수: 3
Guillaume
2019년 6월 18일
Your code is indeed very confusing. There's certainly no explanation why you're first sampling your Array_A every row, then every two rows, then ..., then every 16 rows. It's also unclear why you convert the array to a table. As far as I can tell you don't use any table feature. And finally, why are you sorting the array (repeatedly, at that)?
i need to pull the all of the columns of the rows where column 8 is equal to one ...
That's easily done:
filteredarray = youraray(yourarray(:, 8) == 1);
... in each run
What's a run?
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!