How to remove compare 2 arrays so that when there is a in a column, it removes the column in another array

1 次查看(过去 30 天)
cvs_data =csvread('spruce tree timber quality.csv',1,0)
expert_ratings = cvs_data(:,12)' %inputs
inputs = cvs_data(:,1:11)';
correct_labels = zeros(3,length(expert_ratings));
bad = 0;
good=0;
excellent=0;
histogram(expert_ratings)
Skew1 = skewness(expert_ratings)
for k =1 : length(expert_ratings)%length(expert_ratings)
quality = cvs_data(k,12)';
if quality >= 1 && quality <=4
bad = bad+1;
correct_labels(1:3, k) =[1; 0 ; 0];
end
if quality >= 5 && quality <=6
good = good+1;
correct_labels(1:3, k) =[0; 1 ; 0];
end
if quality >= 7 && quality <=10
excellent = excellent+1;
correct_labels(1:3, k) =[0; 0 ; 1];
end
end
bad
good
excellent
correct_labels
%find bad data
%remove bad data or average it to make it good
%select the same amount of data for all qualities of trees
%remove noise from data
[good_data,rows_rem] = rmoutliers(cvs_data)
transposed_rows = rows_rem'
correct_labels
Hello. I am trying to remove a column from the correct_labels array, when there is a 0 in the corresponding column in the transposed_rows array. How could I go about doing this? Any help would be greatly appreciated.

采纳的回答

dpb
dpb 2022-10-9
编辑:dpb 2022-10-9
You have only one row logical but three rows of labels???
But, assuming that's expected and the need is to remove all columns that are false, that means KEEP those for which is true --
correct_labels=correct_labels(:,transposed_rows);
From the above, sample of the data, looks like you're ony going to keep a very small fraction...sure you're interpreting this correctly?
If, indeed, it is the obverse, then
correct_labels=correct_labels(:,~transposed_rows); % keep those columns NOT true
or, instead of keeping; remove others...
correct_labels(:,transposed_rows)=[]; % remove those columns ARE true

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Tables 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by