Look and extract numbers within a range in MATLAB

7 ビュー (過去 30 日間)
Nejc
Nejc 2013 年 3 月 19 日
Hi, i am still learning about matlab, so here is my question. I got two matrix dimension mx3 and nx3.
A=[2,2345,111; 2,2344,3000; 4, 2345,200 ; 4,2000,200; 2,2346,22; 4,2111,1; 4,3111,1]
B=[2,2345,112; 2,2344,3110; 4, 2345,192 ; 4,2000,184; 2,2346,22; 4,2111,456]
Lets say we are looking for 3rd column. A(:,3) are condition for B(:,3).What i want to do is to extract all rows that value from A column 3 is in range of value from B+-10%
Example:
Lets take first row from A: 2,2345,111 and B: 2,2345,112. Value 112 is within a range 10% deviation of 111, so we extract those rows in a new matrix. If we take second row we see that 3110 is bigger than 3000+-10%, so we dont extract that in new matrix.
I hope you understood my question. Thank you very much in advance.
Nice day, Nejc

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 3 月 19 日
編集済み: Azzi Abdelmalek 2013 年 3 月 19 日
A=[2,2345,111;2,2344,3000;4,2345,200;4,2000,200; 2,2346,22; 4,2111,1; 4,3111,1]
B=[2,2345,112;2,2344,3110;4,2345,192;4,2000,184;2,2346,22;4,2111,456;4,3110,1]
C=A(abs(A(:,3)-B(:,3))<=abs(B(:,3)*.1),:)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by