仅选择满足条件的特定行数
我目前开始使用八度进行一些数据分析,并且在特定的矩阵操作方面遇到一些问题。
假设您有以下数据矩阵:
A = 1 11 22 33 44 13 12 33 1 14 33 44
现在我想删除该矩阵中未满足以下条件的所有行。
octave:6> A(:, 4) == 33 ans = 1 1 0
我将得到这种形式的矩阵,它只选择这些行:
A_new = 1 11 22 33 44 13 12 33
我知道在一些循环的帮助下这是可能的。但是是否有一个更干净的解决方案,例如通过使用提供的标准库?那太好了:]
R 也已经发布了一些类似的问题: 在 R 中,选择矩阵中满足条件的行一个条件
I currently started to work with octave for some data analysis and have some problems for a specific matrix manipulation.
Assume you have the following data matrix:
A = 1 11 22 33 44 13 12 33 1 14 33 44
Now I would like to delete all rows of this matrix which don't accomplish e.g. the following condition.
octave:6> A(:, 4) == 33 ans = 1 1 0
And I'll get the matrix of this form which only selects these rows:
A_new = 1 11 22 33 44 13 12 33
I know this is possible with the help of some loops. But is there maybe a cleaner solution e.g. by using the provided standard library? That would be great :]
Some similar question was also already posted for R:
In R, select rows of a matrix that meet a condition
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试:
这是使用逻辑索引
Try:
This is using logical indexing