Removing elements from an Array
7 次查看(过去 30 天)
显示 更早的评论
I have two arrays:
A = [0, 1]; and B = [0, 1, 3, 1, 4, 5, 6];
I want to compare the first element of A to the first 3 elements of B and the second element of A to the next 4 elements of B. If the elements of A are equal I delete it from B. So in simple:
if (A(1) == B(1:3))
delete A(1) from B
Similarly
if (A(2) == B(4:7))
delete A(2) from B
Is there any way I can do this without having to enter the indices in a hard coded manner?
So in the end B should have the following elements:
B = [1, 3, 4, 5, 6];
3 个评论
Jan
2018-6-22
Is this the same problem as in your thread https://www.mathworks.com/matlabcentral/answers/406790-removing-elements-from-an-array-based-on-their-position-for-every-3-elements? Then it is solved there.
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!