Deleting rows with specific values within a matrix
显示 更早的评论
Here is the given question:
Create a matrix, A, of dimension
of random integers in the range
. Now create a new matrix from A by removing any rows that contains either -10, 0, 10.
. Now create a new matrix from A by removing any rows that contains either -10, 0, 10. I have create the random matrix
A = randi([-10, 10], [7,12])
Despite looking online, I am yet to find anything similar.
Thanks for the help.
4 个评论
Jan
2021-4-6
This sounds like a homework question. Then please post, what you have tried so far and ask a specific question. It is not useful, if the forum solves your homework.
Lewis Abrams
2021-4-6
编辑:Rena Berman
2021-5-6
Rena Berman
2021-5-6
(Answers Dev) Restored edit
Matt J
2021-5-6
A record of the original question:
Here is the given question:
Create a matrix, A, of dimension of random integers in the range . Now create a new matrix from A by removing any rows that contains either -10, 0, 10.
I have create the random matrix
A = randi([-10, 10], [7,12])
Despite looking online, I am yet to find anything similar.
Thanks for the help.
回答(1 个)
Hint: do something with this line:
ind = any( A==0 | abs(A)==10 ,2)
2 个评论
Lewis Abrams
2021-4-6
编辑:Rena Berman
2021-5-6
abs() is absolute value.
c=abs([-10, 10])
The line I've shown you really is by far the hardest part. If you don't know what to do from here, I think you need to review the Matlab on-ramp material.
类别
在 帮助中心 和 File Exchange 中查找有关 Mathematics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!