フィルターのクリア

While/for loop to write a set of values only when they are in a certain range.

1 回表示 (過去 30 日間)
So, I have a variable called XY. An whos on that variable 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. For instance, in the example above I only want to write A and B to excel, when both A and B are within 400-500. So I only want to write the last 3 sets, and not the 2 on the top. What is the easies way to go about this?

採用された回答

Jacob Halbrooks
Jacob Halbrooks 2012 年 3 月 12 日
I would suggest a combination of ALL with logical indexing and masking:
dataToWrite = XY(all((XY >= 400) & (XY <= 500), 2),:);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by