Search data clusters and saving them.

2 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by