MATLAB Answers

0

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

Pedro Guevara さんによって質問されました 2019 年 4 月 30 日
最新アクティビティ Walter Roberson
さんによって 回答されました 2019 年 4 月 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

  0 件のコメント

サインイン to comment.

製品


リリース

R2017b

1 件の回答

回答者: 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.

  0 件のコメント

サインイン to comment.



Translated by