Search for an element belonging to a matrix, but not taken into account in the search.
2 views (last 30 days)
Show older comments
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
0 Comments
Answers (1)
Walter Roberson
on 30 Apr 2019
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.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!