Info
此问题已关闭。 请重新打开它进行编辑或回答。
How to check criterion seqentially
1 次查看(过去 30 天)
显示 更早的评论
Hi Input1:
3.3 5.7 6.1
7.0 5.0 2.0
3.0 4.7 1.4
5.4 0.0 2.0
1.6 0.0 1.0
1.3 5.2 1.8
1.0 10.4 2.6
0.7 15.6 3.4
0.4 20.8 4.2
5.4 0.0 2.0
1.6 0.0 1.0
Input2
2
4
6
2
24
14
11
24
30
13
24
I want check:
Criterion1: Find if any data(<=2), if no data existe under this criterion, then go to criterion2 if data exist, then find the row index satisfying, and extract the rows from input1.
Data_match:
3.3 5.7 6.1
5.4 0.0 2.0
Criterion2: When 1st criterion fails: Find if any data(<=24), if data exist, then find the row index satisfying, and extract the rows from input1
Criterion3: If criterion1&2 fail, then Data_match=Input1
I use the following code (want to know any other efficient way):
tic
input=[2 3.3 5.7 6.1
4 7.0 5.0 2.0
6 3.0 4.7 1.4
2 5.4 0.0 2.0
24 1.6 0.0 1.0
14 1.3 5.2 1.8
11 1.0 10.4 2.6
24 0.7 15.6 3.4
30 0.4 20.8 4.2
13 5.4 0.0 2.0
24 1.6 0.0 1.0];
timeCol=input(:,1);
xx2h =find(timeCol(:,1)<= 1);
xx24h =find((timeCol(:,1)<=24));
if((size(xx2h,1)>0))
dataMatch=input(xx2h,:);
disp('come to 2h')
elseif((size(xx24h,1)>0))
dataMatch=input(xx24h,:);
disp('come to 24h')
else
disp('come to original')
dataMatch=input;
end
0 个评论
回答(0 个)
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!