Search data clusters and saving them.

20 ビュー (過去 30 日間)
Jonas Jeskulke
Jonas Jeskulke 2020 年 1 月 6 日
コメント済み: Jonas Jeskulke 2020 年 1 月 17 日
Hello there, i have a problem with writing a script.
The goal of the specific part of script that troubles me is to find values in a certain range inside a matix (so far so easy) and to save them in a new matrix. I calculated angels between 2 vectors: the script calculates the angel between V1 & V1 then V1&V2 then V1&V3... so on , in the next step V2&V2 ... so every vektor with every following, I saved all that data in a Matrix so 1st row is V1& every following, 2. row V2& every following.
Now i want to find clusters. Lets say every value above 0 and not more then equal to 10 is part of a cluster. I want the script not ony going trough every row, i want it to check if the rows are intertwined with each other so if there is a value at the point (1,2) that is 6 i want to save every value of the second row that meets the conditions in the same matrix as the values of the first row.
My Attemt looks like this:
[irow,icol,ind] = find(anr>0 & anr<=10);
irc = [irow,icol];
for i = 1: length(ind)
for is = 2: length(ind);
k(i) = find(irow(i) == irow(is));
[cro(i)] = icol(is) == irow(i);
end
end
As you can imagin it is not working , i am glad for every Tip and help i can get (i am very stuck with this). If there is a better way to do this i will gladly listen.
Kind Regards Jonas

回答 (1 件)

Mahesh Taparia
Mahesh Taparia 2020 年 1 月 9 日
Hi,
You can directly do by the following lines of code:
X=(anr>0 & anr<=10);
Y=anr.*X;
Y will contain the required data.
  1 件のコメント
Jonas Jeskulke
Jonas Jeskulke 2020 年 1 月 17 日
Hey,
sry but that is not the problematic part. I got an answer though. Thank you for your efford.
The solving answer can be found here:
https://de.mathworks.com/matlabcentral/answers/499241-unable-to-perform-assignment-because-the-left-and-right-sides-have-a-different-number-of-elements

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by