Search for an element belonging to a matrix, but not taken into account in the search.

조회 수: 2 (최근 30일)
Good morning. I request your help with a problem I am having. What happens is that I have a matrix called "Tab_nodes" and inside it I am looking for an element that in turn is inside the same table. I am using the following line of code to perform the search:
[rowNod1,colNod1]= find( Tab_nodos ( 1:30, 2:3 ) == Tab_nodos( V_org(celdas,1), 2 ) ) ;
The line of code works quite well, just that I do not want that within the search I contemplated the element that I am looking for, I only want the other elements. I hope you can help me with this mishap. Thank you

답변 (1개)

Walter Roberson
Walter Roberson 2019년 4월 30일
Probably the easiest thing to do is filter it out afterwards.
%column to match has to be 2-1 because the column subset 2:3 is being examined, and column 2
%of the original matrix becomes column 1 of the subset of data
mask = rowNod1 == V_org(celdas,1) && colNod1 == 2-1;
rowNod1(mask) = [];
colNod1(mask) = [];
It is possible to remove the entry before doing the find(), but then you have to turn the Tab_nodos(1:30, 2:3) array into a vector (because arrays cannot have a hole in them) and get linear indexes out of find() and make adjustments afterwards.

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by