How to compute percentile share of character values in column vector in a for loop?

3 ビュー (過去 30 日間)
Clara Hollmann
Clara Hollmann 2020 年 10 月 9 日
コメント済み: Rik 2020 年 10 月 9 日
Hello,
I have a column vector 'Colour' that can take on values like ‚Brown‘, ‚Blonde‘ and ‚Black‘ in a bigger matrix of characteristics. I want it to only look at these observations in a larger loop for 'Test' if they have a share above 75% in the vector. So far I used this method:
for n = 1: length(Test.Colour)
if sum(Test.Colour(:) == Test.Colour(n))./numel(Test.Colour).*100 >= 75;
Test = Test(Test.Colour == Test.Colour(n,:));
else Test = NaN
end
end
but I get the error ‘Dot indexing is not supported for variables of this type’. Does anyone know how to go around solving this?

回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by