Look and extract numbers within a range in MATLAB
1 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!