我有两个矩阵A “只有一列”而B有多个colomn但行数与A相同,如下所示,我想做的是检查A中的行,其中元素等于-1并删除从矩阵A和B中删除此行,所以在下面的示例中,我想从矩阵A和B中删除行索引3和6,任何建议?
A= 6 3 -1 6 6 -1 2 4 and B= -0.511774504646677 0.435674206557952 1.07400000000000 -0.509871997194459 0.437576714010170 1.07400000000000 -0.507969489742241 0.439479221462388 1.07400000000000 -0.506586007364545 0.429374013677012 1.07100000000000 -0.504201297562686 0.439754515167456 1.07100000000000 -0.501883219358233 0.428847974750132 1.07100000000000 -0.501415044713309 0.431930562861652 1.07100000000000 -0.499537085744345 0.433808521830616 1.07100000000000I have two matrices A "only has one column" and B which has more than one colomn but the same number of rows as A as shown below, what I want to do is to check the rows in A which has elements equal to -1 and remove delete this row from both matrices A and B, so in the example below I want to delete row index 3 and 6 from both matrices A and B, any advise?
A= 6 3 -1 6 6 -1 2 4 and B= -0.511774504646677 0.435674206557952 1.07400000000000 -0.509871997194459 0.437576714010170 1.07400000000000 -0.507969489742241 0.439479221462388 1.07400000000000 -0.506586007364545 0.429374013677012 1.07100000000000 -0.504201297562686 0.439754515167456 1.07100000000000 -0.501883219358233 0.428847974750132 1.07100000000000 -0.501415044713309 0.431930562861652 1.07100000000000 -0.499537085744345 0.433808521830616 1.07100000000000最满意答案
使用基于A逻辑索引:
B=B(A~=-1,:); A=A(A~=-1);Use logical indexing based on A:
B=B(A~=-1,:); A=A(A~=-1);删除矩阵Matlab中的行(Delete row in a matrix Matlab)我有两个矩阵A “只有一列”而B有多个colomn但行数与A相同,如下所示,我想做的是检查A中的行,其中元素等于-1并删除从矩阵A和B中删除此行,所以在下面的示例中,我想从矩阵A和B中删除行索引3和6,任何建议?
A= 6 3 -1 6 6 -1 2 4 and B= -0.511774504646677 0.435674206557952 1.07400000000000 -0.509871997194459 0.437576714010170 1.07400000000000 -0.507969489742241 0.439479221462388 1.07400000000000 -0.506586007364545 0.429374013677012 1.07100000000000 -0.504201297562686 0.439754515167456 1.07100000000000 -0.501883219358233 0.428847974750132 1.07100000000000 -0.501415044713309 0.431930562861652 1.07100000000000 -0.499537085744345 0.433808521830616 1.07100000000000I have two matrices A "only has one column" and B which has more than one colomn but the same number of rows as A as shown below, what I want to do is to check the rows in A which has elements equal to -1 and remove delete this row from both matrices A and B, so in the example below I want to delete row index 3 and 6 from both matrices A and B, any advise?
A= 6 3 -1 6 6 -1 2 4 and B= -0.511774504646677 0.435674206557952 1.07400000000000 -0.509871997194459 0.437576714010170 1.07400000000000 -0.507969489742241 0.439479221462388 1.07400000000000 -0.506586007364545 0.429374013677012 1.07100000000000 -0.504201297562686 0.439754515167456 1.07100000000000 -0.501883219358233 0.428847974750132 1.07100000000000 -0.501415044713309 0.431930562861652 1.07100000000000 -0.499537085744345 0.433808521830616 1.07100000000000最满意答案
使用基于A逻辑索引:
B=B(A~=-1,:); A=A(A~=-1);Use logical indexing based on A:
B=B(A~=-1,:); A=A(A~=-1);
发布评论