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

조회 수: 1 (최근 30일)
Triveni
Triveni 2016년 2월 28일
댓글: Triveni 2016년 2월 29일
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

채택된 답변

the cyclist
the cyclist 2016년 2월 28일
I'm not 100% certain I understand your question, but I think this does what you want:
y(c<3,:) = [];
  댓글 수: 7
Image Analyst
Image Analyst 2016년 2월 29일
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 2016년 2월 29일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by