Search data clusters and saving them.

조회 수: 1 (최근 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 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