Azzera filtri
Azzera filtri

Trying to pull intermittent errors from an array

1 visualizzazione (ultimi 30 giorni)
Sumara
Sumara il 18 Giu 2019
Commentato: Sumara il 18 Giu 2019
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 Commenti
Guillaume
Guillaume il 18 Giu 2019
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?
Sumara
Sumara il 18 Giu 2019
  1. I'm sorting Array_A based upon the number of different inputs put in in another section of code, and I need the output tables for each of the 'num' options and as well as the final table for individual analysis. It is exporting 'num' tables.
  2. I sort the tables prior to execution for convenience.
  3. 'run' is the value of 'num', apologies for that lack of clarity.
I'm sorry, it appears my question wasn't specific/detailed enough... I'll try to clarify
I need to filter the array for the rows that contain a value of 1 in the 8th column for each number 1:num, which is easy enough
filteredarray = youraray(yourarray(:, 8) == 1);
then the char in the 1st column of that row will be compared to a pre-existing char, that is different for each value of num and I'll need the sum of those values that do not equal the pre-existing char
char = char = ['K';'J';'I';'L';'A';'B';'C';'D';'E';'F';'G';'H';'I';'J';'K';'L']
total_errors = sum(filteredarray(:,1)~=char)
but I need the total_errors for the values 1:num in a numx1 array?
I don't know if I made this any more clear.... I'm not very good at explaining things

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Startup and Shutdown in Help Center e File Exchange

Prodotti


Release

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by