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 Center および File ExchangeMatrix Indexing についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by