While/for loop to write a set of values, varying in each column, when they are both in a certain range.
Mostrar comentarios más antiguos
So, I asked a similar question earlier, but I had made an assumption about my data, that did not hold up. The variable I am working with looks like this:
Name Size Bytes Class Attributes
XY 2897x2 46352 double
A snippet of that variable looks like is this:
A B
527 393
523 397
513 409
506 411
509 412
What I need is a while/for loop that will write the values of XY to a new variable (lets call it XY2) only when both A and B column is in certain value range. But this varies individually for column A and B. For instance, I ONLY want to write to XY2 values when A=510-530 and B=400-420. This would mean that I would only write the following value:
513 409
Las time I was given this code, which worked beautifully (in future works I think that I could use that one):
XY2 = XY(all((XY >= 165) & (XY <= 371), 2),:);
Credits given to user Jacob Halbrooks btw, for that code =)
My own attempts to alter this one, to make it fit with my data, did not work at all. My background is not in programming, so I am patching together my code with the help of forums like this, and stuff I have managed to figure out myself. I use the code to extract data for my master thesis.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Data Type Conversion en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!