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
0 个评论
回答(1 个)
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!