How to control number of element or number of unique element in Matrix?

1 vue (au cours des 30 derniers jours)
Triveni
Triveni le 28 Fév 2016
Commenté : Triveni le 29 Fév 2016
x= [15 30 45 60 -45 -30 0 90 15 30 45 60 -45 -30 0 90 15 45 60 -45 -30 0];%Initial guess
a = unique(x); % unique elements
[countingofangles, Thetaangles] = hist(x,unique(x)); % Unique Theta and counting of theta
A = Thetaangles; % Theta used in initial guess x
c = countingofangles; %No of theta used in initial guess x
y = repmat(x,numel(a),1); %repeat x matrix
y(:,end) = a'; %replace last column by transpose(a)
output
A =
-45 -30 0 15 30 45 60 90 %Theta used in x
c =
3 3 3 3 2 3 3 2 %Number of theta corresponding to A
y =
15 30 45 60 -45 -30 0 90 15 30 45 60 -45 -30 0 90 15 45 60 -45 -30 -45
15 30 45 60 -45 -30 0 90 15 30 45 60 -45 -30 0 90 15 45 60 -45 -30 -30
15 30 45 60 -45 -30 0 90 15 30 45 60 -45 -30 0 90 15 45 60 -45 -30 0
15 30 45 60 -45 -30 0 90 15 30 45 60 -45 -30 0 90 15 45 60 -45 -30 15
15 30 45 60 -45 -30 0 90 15 30 45 60 -45 -30 0 90 15 45 60 -45 -30 30
15 30 45 60 -45 -30 0 90 15 30 45 60 -45 -30 0 90 15 45 60 -45 -30 45
15 30 45 60 -45 -30 0 90 15 30 45 60 -45 -30 0 90 15 45 60 -45 -30 60
15 30 45 60 -45 -30 0 90 15 30 45 60 -45 -30 0 90 15 45 60 -45 -30 90
I want to eliminate/delete that row which contains no of theta/counting of theta/angles(15,30, 45 etc) less than 3

Réponse acceptée

the cyclist
the cyclist le 28 Fév 2016
I'm not 100% certain I understand your question, but I think this does what you want:
y(c<3,:) = [];
  7 commentaires
Image Analyst
Image Analyst le 29 Fév 2016
Generally you would NOT want to throw out bins at various places in the histogram. It would make it very difficult and deceiving to try to use the arrays afterwards.
Triveni
Triveni le 29 Fév 2016
Lot of thanks Sir, Actually i developing an algorithm, that's why i need this type of array. Lastly please help me once again, I have a Matrix.
y =[ 90 90 -45 0 0 45 45 0 -45 15 30 -30 75 -45 75 -75
90 90 -45 0 0 -45 -45 0 -45 15 30 -30 75 -45 75 -45
90 90 -45 0 0 45 45 0 -45 15 30 -30 75 -45 75 -30
90 90 -45 0 0 45 45 0 -45 15 30 -30 75 -45 75 0
90 90 -45 0 0 45 45 0 -45 15 30 -30 75 -45 75 15
90 90 -45 0 0 45 45 0 -45 15 30 -30 75 -45 75 30
90 90 45 0 0 45 45 0 45 15 30 -30 75 45 75 45
90 90 -45 0 0 45 45 0 -45 15 30 -30 75 -45 75 75
90 90 -45 0 0 45 45 0 -45 15 30 -30 75 -45 75 90];
unique(y) =9;
Sir tell me to count unique value in every row, and if unique elements in row less than 9, should be deleted. I hope you would do it for me.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by