I need to delete some rows in an array based on if their column values fall inside a range
Show older comments
I have a Nx3 matrix A. I have my conditions: xlo = 0; xhi = 100; ylo = 0; yhi = 100; zlo = 0; zhi = 100; I want to be able to go through the matrix and start at row 1, and check that the value in A(1:1) falls between xlo and xhi if it does not I want it to delete that row and move to the next row. In case that the value in A(1:1) falls between xlo and xhi I want it to move to A(1:2) and I want the value in this cell to fall between ylo and yhi, if it doesnt I want it to delete the row and move to the next one. In case the value in A(1:2) falls within the ylo and yhi range then I want it to move to check A(1:3). A(1:3) should be in the range between zlo and zhi. If it is not in between the range then delete the row and move to the next row. If all conditions are satisfactory I want it to output that row into a new matrix that is going to be a Mx3. M being the number of all the rows that passed the conditions
Accepted Answer
More Answers (1)
Jose Martinez
on 24 Oct 2018
3 Comments
As you can see in my example the code works properly. If the output B is empty , either there are no values in A meeting all the conditions you have or possibly the conditions are choosen bad.
However the way to tacle this kind of problem is shown in this answer.
To correct the error message you can replace && by & and | | by |.
Jose Martinez
on 24 Oct 2018
Stephan
on 24 Oct 2018
Please accept helpful answers in order to help people with similar Problems find helpful answers.
Categories
Find more on Surrogate Optimization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!