現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
extract a row of 2D array based on constant 2D array values
4 ビュー (過去 30 日間)
古いコメントを表示
Min
2023 年 10 月 3 日
hi I am trying to pull out / extract number of rows from a 2D array data based off from another 2D array (1 row).
For example,
A = [90 10 21; 90 20 21; 90 30 21; 90 40 22; 90 50 21; 88 10 20; 88 20 20; 88 30 24;
88 40 22; 88 50 21; 86 10 20; 86 20 21; 86 30 20; 86 40 25; 86 50 20]
A = 15×3
90 10 21
90 20 21
90 30 21
90 40 22
90 50 21
88 10 20
88 20 20
88 30 24
88 40 22
88 50 21
B = [14 26 30 47]
B = 1×4
14 26 30 47
result = [90 10 21; 90 30 21; 90 30 21; 90 50 21; 88 10 20; 88 30 24;
88 30 24; 88 50 21; 86 10 20; 86 30 20; 86 30 20; 86 50 20]
result = 12×3
90 10 21
90 30 21
90 30 21
90 50 21
88 10 20
88 30 24
88 30 24
88 50 21
86 10 20
86 30 20
I want to pull the entire row of A if the 2nd column of A has the closest value from B. But the second column of A is repeating 10 - 50.
I tried the interp1 (A,A,B,'nearest') but it does not work since B must be a target value.
Can you suggest any other solutions?
4 件のコメント
Cris LaPierre
2023 年 10 月 3 日
It would be helpful if you could share which row(s) of A should be extracted in the example you have shared.
Min
2023 年 10 月 3 日
I just updated the question based on your question, so I am trying to extract any rows that has the neared value of column 2 of A respect to B. Hopefully this makes sense to you.
Dyuman Joshi
2023 年 10 月 3 日
The criteria/logic to get the output result from the inputs A and B is still not clear to me.
Could you elaborate on it?
Min
2023 年 10 月 3 日
Sure!
Well a quick update is that it does not need to be nearest anymore. I just found a way to get those values.
I was wondering if there is a way to extract a number of rows based on the 'B' array values.
So
let's say
A Column name: Column 1 = Distance, Column 2 = Angle, Column 3 = something else
where A = [90, 10, 21; 90, 20, 21; 90, 30, 21; 90, 40, 22; 90, 50, 21; 88, 10, 20; 88, 20, 20; 88, 30, 24; 88, 40, 22; 88, 50, 21; 86, 10, 20; 86, 20, 21; 86, 30, 20; 86, 40, 25; 86, 50, 20]
Then based on the Array 'B' where B = [14; 26; 30; 47]
Then it will select and extract the a number of rows from A when column 2 of A has the nearest B values.
Essentially, extracting the rows when it matches another array.
採用された回答
Voss
2023 年 10 月 3 日
編集済み: Voss
2023 年 10 月 3 日
A = [90 10 21; 90 20 21; 90 30 21; 90 40 22; 90 50 21; 88 10 20; 88 20 20; 88 30 24; 88 40 22; 88 50 21; 86 10 20; 86 20 21; 86 30 20; 86 40 25; 86 50 20]
A = 15×3
90 10 21
90 20 21
90 30 21
90 40 22
90 50 21
88 10 20
88 20 20
88 30 24
88 40 22
88 50 21
B = [14; 26; 30; 47]
B = 4×1
14
26
30
47
[~,~,jj] = unique(A(:,1),'stable');
result = splitapply(@(x)get_rows_near(x,B(:).'),A,jj);
result = vertcat(result{:});
disp(result);
90 10 21
90 30 21
90 30 21
90 50 21
88 10 20
88 30 24
88 30 24
88 50 21
86 10 20
86 30 20
86 30 20
86 50 20
function out = get_rows_near(x,B)
[~,idx] = min(abs(x(:,2)-B),[],1);
out = {x(idx,:)};
end
6 件のコメント
Min
2023 年 10 月 3 日
Sure! Here is the code, I will also share the workspace of each variables.
[~,~,jj] = unique(remote_gain_value_specified(:,2),'stable');
result = splitapply(@(x)get_rows_near(x,theta_raw(:)'),remote_gain_value_specified,jj);
result = vertcat(result{:});
disp(result);
%% Function
function out = get_rows_near(x,theta_raw)
[~,idx] = min(abs(x(:,2)-theta_raw),[],1);
out = {x(idx,:)};
end
Voss
2023 年 10 月 3 日
編集済み: Voss
2023 年 10 月 3 日
load('remote_gain_value_specified.mat')
load('theta_raw.mat')
disp(remote_gain_value_specified)
2.4500 86.0000 0 21.4611
2.4500 86.0000 2.0000 21.2171
2.4500 86.0000 4.0000 21.0005
2.4500 86.0000 6.0000 20.7968
2.4500 86.0000 8.0000 20.5718
2.4500 86.0000 10.0000 20.2857
2.4500 86.0000 12.0000 19.9182
2.4500 86.0000 14.0000 19.5094
2.4500 86.0000 16.0000 19.2150
2.4500 86.0000 18.0000 19.3157
2.4500 86.0000 20.0000 20.0376
2.4500 86.0000 22.0000 21.2927
2.4500 86.0000 24.0000 22.7602
2.4500 86.0000 26.0000 24.1587
2.4500 86.0000 28.0000 25.3342
2.4500 86.0000 30.0000 26.2173
2.4500 86.0000 32.0000 26.7769
2.4500 86.0000 34.0000 26.9931
2.4500 86.0000 36.0000 26.8455
2.4500 86.0000 38.0000 26.3080
2.4500 86.0000 40.0000 25.3556
2.4500 86.0000 42.0000 24.0072
2.4500 86.0000 44.0000 22.5006
2.4500 86.0000 46.0000 21.6825
2.4500 86.0000 48.0000 22.5711
2.4500 86.0000 50.0000 24.6370
2.4500 86.0000 52.0000 26.8160
2.4500 86.0000 54.0000 28.7040
2.4500 86.0000 56.0000 30.2509
2.4500 86.0000 58.0000 31.4922
2.4500 86.0000 60.0000 32.4726
2.4500 86.0000 62.0000 33.2299
2.4500 86.0000 64.0000 33.7945
2.4500 86.0000 66.0000 34.1911
2.4500 86.0000 68.0000 34.4409
2.4500 86.0000 70.0000 34.5636
2.4500 86.0000 72.0000 34.5786
2.4500 86.0000 74.0000 34.5060
2.4500 86.0000 76.0000 34.3668
2.4500 86.0000 78.0000 34.1828
2.4500 86.0000 80.0000 33.9756
2.4500 86.0000 82.0000 33.7648
2.4500 86.0000 84.0000 33.5659
2.4500 86.0000 86.0000 33.3881
2.4500 86.0000 88.0000 33.2326
2.4500 86.0000 90.0000 33.0932
2.4500 86.0000 92.0000 32.9581
2.4500 86.0000 94.0000 32.8124
2.4500 86.0000 96.0000 32.6422
2.4500 86.0000 98.0000 32.4365
2.4500 86.0000 100.0000 32.1897
2.4500 86.0000 102.0000 31.9026
2.4500 86.0000 104.0000 31.5819
2.4500 86.0000 106.0000 31.2397
2.4500 86.0000 108.0000 30.8910
2.4500 86.0000 110.0000 30.5503
2.4500 86.0000 112.0000 30.2278
2.4500 86.0000 114.0000 29.9268
2.4500 86.0000 116.0000 29.6421
2.4500 86.0000 118.0000 29.3610
2.4500 86.0000 120.0000 29.0659
2.4500 86.0000 122.0000 28.7371
2.4500 86.0000 124.0000 28.3562
2.4500 86.0000 126.0000 27.9083
2.4500 86.0000 128.0000 27.3850
2.4500 86.0000 130.0000 26.7873
2.4500 86.0000 132.0000 26.1296
2.4500 86.0000 134.0000 25.4436
2.4500 86.0000 136.0000 24.7792
2.4500 86.0000 138.0000 24.1990
2.4500 86.0000 140.0000 23.7603
2.4500 86.0000 142.0000 23.4914
2.4500 86.0000 144.0000 23.3796
2.4500 86.0000 146.0000 23.3822
2.4500 86.0000 148.0000 23.4508
2.4500 86.0000 150.0000 23.5505
2.4500 86.0000 152.0000 23.6626
2.4500 86.0000 154.0000 23.7767
2.4500 86.0000 156.0000 23.8792
2.4500 86.0000 158.0000 23.9469
2.4500 86.0000 160.0000 23.9476
2.4500 86.0000 162.0000 23.8458
2.4500 86.0000 164.0000 23.6104
2.4500 86.0000 166.0000 23.2207
2.4500 86.0000 168.0000 22.6728
2.4500 86.0000 170.0000 21.9892
2.4500 86.0000 172.0000 21.2327
2.4500 86.0000 174.0000 20.5200
2.4500 86.0000 176.0000 20.0083
2.4500 86.0000 178.0000 19.8228
2.4500 86.0000 180.0000 19.9636
2.4500 88.0000 0 21.4611
2.4500 88.0000 2.0000 21.2296
2.4500 88.0000 4.0000 21.0294
2.4500 88.0000 6.0000 20.8388
2.4500 88.0000 8.0000 20.6171
2.4500 88.0000 10.0000 20.3179
2.4500 88.0000 12.0000 19.9140
2.4500 88.0000 14.0000 19.4391
2.4500 88.0000 16.0000 19.0524
2.4500 88.0000 18.0000 19.0698
2.4500 88.0000 20.0000 19.7752
2.4500 88.0000 22.0000 21.0880
2.4500 88.0000 24.0000 22.6425
2.4500 88.0000 26.0000 24.1240
2.4500 88.0000 28.0000 25.3698
2.4500 88.0000 30.0000 26.3128
2.4500 88.0000 32.0000 26.9251
2.4500 88.0000 34.0000 27.1889
2.4500 88.0000 36.0000 27.0826
2.4500 88.0000 38.0000 26.5730
2.4500 88.0000 40.0000 25.6118
2.4500 88.0000 42.0000 24.1504
2.4500 88.0000 44.0000 22.2542
2.4500 88.0000 46.0000 20.6166
2.4500 88.0000 48.0000 20.9779
2.4500 88.0000 50.0000 23.3039
2.4500 88.0000 52.0000 25.8797
2.4500 88.0000 54.0000 28.0600
2.4500 88.0000 56.0000 29.8045
2.4500 88.0000 58.0000 31.1807
2.4500 88.0000 60.0000 32.2548
2.4500 88.0000 62.0000 33.0779
2.4500 88.0000 64.0000 33.6891
2.4500 88.0000 66.0000 34.1192
2.4500 88.0000 68.0000 34.3940
2.4500 88.0000 70.0000 34.5367
2.4500 88.0000 72.0000 34.5693
2.4500 88.0000 74.0000 34.5133
2.4500 88.0000 76.0000 34.3904
2.4500 88.0000 78.0000 34.2223
2.4500 88.0000 80.0000 34.0296
2.4500 88.0000 82.0000 33.8308
2.4500 88.0000 84.0000 33.6398
2.4500 88.0000 86.0000 33.4648
2.4500 88.0000 88.0000 33.3064
2.4500 88.0000 90.0000 33.1584
2.4500 88.0000 92.0000 33.0097
2.4500 88.0000 94.0000 32.8466
2.4500 88.0000 96.0000 32.6557
2.4500 88.0000 98.0000 32.4269
2.4500 88.0000 100.0000 32.1544
2.4500 88.0000 102.0000 31.8386
2.4500 88.0000 104.0000 31.4855
2.4500 88.0000 106.0000 31.1072
2.4500 88.0000 108.0000 30.7198
2.4500 88.0000 110.0000 30.3408
2.4500 88.0000 112.0000 29.9854
2.4500 88.0000 114.0000 29.6622
2.4500 88.0000 116.0000 29.3701
2.4500 88.0000 118.0000 29.0972
2.4500 88.0000 120.0000 28.8233
2.4500 88.0000 122.0000 28.5236
2.4500 88.0000 124.0000 28.1738
2.4500 88.0000 126.0000 27.7535
2.4500 88.0000 128.0000 27.2508
2.4500 88.0000 130.0000 26.6647
2.4500 88.0000 132.0000 26.0093
2.4500 88.0000 134.0000 25.3162
2.4500 88.0000 136.0000 24.6356
2.4500 88.0000 138.0000 24.0303
2.4500 88.0000 140.0000 23.5590
2.4500 88.0000 142.0000 23.2544
2.4500 88.0000 144.0000 23.1108
2.4500 88.0000 146.0000 23.0931
2.4500 88.0000 148.0000 23.1583
2.4500 88.0000 150.0000 23.2727
2.4500 88.0000 152.0000 23.4145
2.4500 88.0000 154.0000 23.5662
2.4500 88.0000 156.0000 23.7064
2.4500 88.0000 158.0000 23.8052
2.4500 88.0000 160.0000 23.8273
2.4500 88.0000 162.0000 23.7380
2.4500 88.0000 164.0000 23.5089
2.4500 88.0000 166.0000 23.1231
2.4500 88.0000 168.0000 22.5811
2.4500 88.0000 170.0000 21.9090
2.4500 88.0000 172.0000 21.1721
2.4500 88.0000 174.0000 20.4858
2.4500 88.0000 176.0000 19.9998
2.4500 88.0000 178.0000 19.8276
2.4500 88.0000 180.0000 19.9636
2.4500 90.0000 0 21.4611
2.4500 90.0000 2.0000 21.2422
2.4500 90.0000 4.0000 21.0581
2.4500 90.0000 6.0000 20.8810
2.4500 90.0000 8.0000 20.6643
2.4500 90.0000 10.0000 20.3562
2.4500 90.0000 12.0000 19.9229
2.4500 90.0000 14.0000 19.3902
2.4500 90.0000 16.0000 18.9160
2.4500 90.0000 18.0000 18.8448
2.4500 90.0000 20.0000 19.5215
2.4500 90.0000 22.0000 20.8823
2.4500 90.0000 24.0000 22.5182
2.4500 90.0000 26.0000 24.0802
2.4500 90.0000 28.0000 25.3973
2.4500 90.0000 30.0000 26.4041
2.4500 90.0000 32.0000 27.0770
2.4500 90.0000 34.0000 27.4013
2.4500 90.0000 36.0000 27.3572
2.4500 90.0000 38.0000 26.9100
2.4500 90.0000 40.0000 26.0002
2.4500 90.0000 42.0000 24.5354
2.4500 90.0000 44.0000 22.4173
2.4500 90.0000 46.0000 19.8797
2.4500 90.0000 48.0000 18.9401
2.4500 90.0000 50.0000 21.3597
2.4500 90.0000 52.0000 24.4974
2.4500 90.0000 54.0000 27.0821
2.4500 90.0000 56.0000 29.0874
2.4500 90.0000 58.0000 30.6370
2.4500 90.0000 60.0000 31.8312
2.4500 90.0000 62.0000 32.7404
2.4500 90.0000 64.0000 33.4151
2.4500 90.0000 66.0000 33.8935
2.4500 90.0000 68.0000 34.2068
2.4500 90.0000 70.0000 34.3817
2.4500 90.0000 72.0000 34.4428
2.4500 90.0000 74.0000 34.4132
2.4500 90.0000 76.0000 34.3153
2.4500 90.0000 78.0000 34.1703
2.4500 90.0000 80.0000 33.9982
2.4500 90.0000 82.0000 33.8160
2.4500 90.0000 84.0000 33.6368
2.4500 90.0000 86.0000 33.4679
2.4500 90.0000 88.0000 33.3102
2.4500 90.0000 90.0000 33.1583
2.4500 90.0000 92.0000 33.0024
2.4500 90.0000 94.0000 32.8302
2.4500 90.0000 96.0000 32.6300
2.4500 90.0000 98.0000 32.3923
2.4500 90.0000 100.0000 32.1119
2.4500 90.0000 102.0000 31.7887
2.4500 90.0000 104.0000 31.4284
2.4500 90.0000 106.0000 31.0424
2.4500 90.0000 108.0000 30.6470
2.4500 90.0000 110.0000 30.2607
2.4500 90.0000 112.0000 29.9005
2.4500 90.0000 114.0000 29.5773
2.4500 90.0000 116.0000 29.2909
2.4500 90.0000 118.0000 29.0287
2.4500 90.0000 120.0000 28.7680
2.4500 90.0000 122.0000 28.4802
2.4500 90.0000 124.0000 28.1373
2.4500 90.0000 126.0000 27.7169
2.4500 90.0000 128.0000 27.2060
2.4500 90.0000 130.0000 26.6046
2.4500 90.0000 132.0000 25.9286
2.4500 90.0000 134.0000 25.2128
2.4500 90.0000 136.0000 24.5100
2.4500 90.0000 138.0000 23.8848
2.4500 90.0000 140.0000 23.3962
2.4500 90.0000 142.0000 23.0769
2.4500 90.0000 144.0000 22.9218
2.4500 90.0000 146.0000 22.8984
2.4500 90.0000 148.0000 22.9663
2.4500 90.0000 150.0000 23.0926
2.4500 90.0000 152.0000 23.2533
2.4500 90.0000 154.0000 23.4263
2.4500 90.0000 156.0000 23.5850
2.4500 90.0000 158.0000 23.6962
2.4500 90.0000 160.0000 23.7238
2.4500 90.0000 162.0000 23.6347
2.4500 90.0000 164.0000 23.4035
2.4500 90.0000 166.0000 23.0172
2.4500 90.0000 168.0000 22.4794
2.4500 90.0000 170.0000 21.8195
2.4500 90.0000 172.0000 21.1046
2.4500 90.0000 174.0000 20.4479
2.4500 90.0000 176.0000 19.9899
2.4500 90.0000 178.0000 19.8322
2.4500 90.0000 180.0000 19.9636
2.4500 92.0000 0 21.4611
2.4500 92.0000 2.0000 21.2548
2.4500 92.0000 4.0000 21.0866
2.4500 92.0000 6.0000 20.9232
2.4500 92.0000 8.0000 20.7130
2.4500 92.0000 10.0000 20.3993
2.4500 92.0000 12.0000 19.9424
2.4500 92.0000 14.0000 19.3591
2.4500 92.0000 16.0000 18.8009
2.4500 92.0000 18.0000 18.6335
2.4500 92.0000 20.0000 19.2658
2.4500 92.0000 22.0000 20.6637
2.4500 92.0000 24.0000 22.3769
2.4500 92.0000 26.0000 24.0195
2.4500 92.0000 28.0000 25.4105
2.4500 92.0000 30.0000 26.4866
2.4500 92.0000 32.0000 27.2281
2.4500 92.0000 34.0000 27.6252
2.4500 92.0000 36.0000 27.6618
2.4500 92.0000 38.0000 27.3067
2.4500 92.0000 40.0000 26.5019
2.4500 92.0000 42.0000 25.1432
2.4500 92.0000 44.0000 23.0523
2.4500 92.0000 46.0000 20.0169
2.4500 92.0000 48.0000 16.9397
2.4500 92.0000 50.0000 18.4984
2.4500 92.0000 52.0000 22.4788
2.4500 92.0000 54.0000 25.6732
2.4500 92.0000 56.0000 28.0429
2.4500 92.0000 58.0000 29.8240
2.4500 92.0000 60.0000 31.1754
2.4500 92.0000 62.0000 32.1972
2.4500 92.0000 64.0000 32.9561
2.4500 92.0000 66.0000 33.5001
2.4500 92.0000 68.0000 33.8666
2.4500 92.0000 70.0000 34.0867
2.4500 92.0000 72.0000 34.1879
2.4500 92.0000 74.0000 34.1950
2.4500 92.0000 76.0000 34.1313
2.4500 92.0000 78.0000 34.0179
2.4500 92.0000 80.0000 33.8741
2.4500 92.0000 82.0000 33.7160
2.4500 92.0000 84.0000 33.5556
2.4500 92.0000 86.0000 33.3999
2.4500 92.0000 88.0000 33.2500
2.4500 92.0000 90.0000 33.1021
2.4500 92.0000 92.0000 32.9480
2.4500 92.0000 94.0000 32.7777
2.4500 92.0000 96.0000 32.5811
2.4500 92.0000 98.0000 32.3504
2.4500 92.0000 100.0000 32.0811
2.4500 92.0000 102.0000 31.7737
2.4500 92.0000 104.0000 31.4337
2.4500 92.0000 106.0000 31.0722
2.4500 92.0000 108.0000 30.7043
2.4500 92.0000 110.0000 30.3470
2.4500 92.0000 112.0000 30.0151
2.4500 92.0000 114.0000 29.7165
2.4500 92.0000 116.0000 29.4483
2.4500 92.0000 118.0000 29.1956
2.4500 92.0000 120.0000 28.9342
2.4500 92.0000 122.0000 28.6353
2.4500 92.0000 124.0000 28.2716
2.4500 92.0000 126.0000 27.8223
2.4500 92.0000 128.0000 27.2765
2.4500 92.0000 130.0000 26.6371
2.4500 92.0000 132.0000 25.9235
2.4500 92.0000 134.0000 25.1743
2.4500 92.0000 136.0000 24.4465
2.4500 92.0000 138.0000 23.8070
2.4500 92.0000 140.0000 23.3142
2.4500 92.0000 142.0000 22.9968
2.4500 92.0000 144.0000 22.8455
2.4500 92.0000 146.0000 22.8252
2.4500 92.0000 148.0000 22.8956
2.4500 92.0000 150.0000 23.0243
2.4500 92.0000 152.0000 23.1866
2.4500 92.0000 154.0000 23.3590
2.4500 92.0000 156.0000 23.5134
2.4500 92.0000 158.0000 23.6164
2.4500 92.0000 160.0000 23.6330
2.4500 92.0000 162.0000 23.5324
2.4500 92.0000 164.0000 23.2918
2.4500 92.0000 166.0000 22.9010
2.4500 92.0000 168.0000 22.3666
2.4500 92.0000 170.0000 21.7204
2.4500 92.0000 172.0000 21.0304
2.4500 92.0000 174.0000 20.4063
2.4500 92.0000 176.0000 19.9789
2.4500 92.0000 178.0000 19.8367
2.4500 92.0000 180.0000 19.9636
2.4500 94.0000 0 21.4611
2.4500 94.0000 2.0000 21.2673
2.4500 94.0000 4.0000 21.1148
2.4500 94.0000 6.0000 20.9652
2.4500 94.0000 8.0000 20.7624
2.4500 94.0000 10.0000 20.4460
2.4500 94.0000 12.0000 19.9702
2.4500 94.0000 14.0000 19.3421
2.4500 94.0000 16.0000 18.7022
2.4500 94.0000 18.0000 18.4293
2.4500 94.0000 20.0000 18.9991
2.4500 94.0000 22.0000 20.4231
2.4500 94.0000 24.0000 22.2118
2.4500 94.0000 26.0000 23.9376
2.4500 94.0000 28.0000 25.4070
2.4500 94.0000 30.0000 26.5582
2.4500 94.0000 32.0000 27.3763
2.4500 94.0000 34.0000 27.8561
2.4500 94.0000 36.0000 27.9875
2.4500 94.0000 38.0000 27.7462
2.4500 94.0000 40.0000 27.0838
2.4500 94.0000 42.0000 25.9086
2.4500 94.0000 44.0000 24.0460
2.4500 94.0000 46.0000 21.1503
2.4500 94.0000 48.0000 16.7189
2.4500 94.0000 50.0000 14.3888
2.4500 94.0000 52.0000 19.4190
2.4500 94.0000 54.0000 23.6569
2.4500 94.0000 56.0000 26.5798
2.4500 94.0000 58.0000 28.6868
2.4500 94.0000 60.0000 30.2509
2.4500 94.0000 62.0000 31.4224
2.4500 94.0000 64.0000 32.2929
2.4500 94.0000 66.0000 32.9239
2.4500 94.0000 68.0000 33.3614
2.4500 94.0000 70.0000 33.6418
2.4500 94.0000 72.0000 33.7963
2.4500 94.0000 74.0000 33.8522
2.4500 94.0000 76.0000 33.8339
2.4500 94.0000 78.0000 33.7631
2.4500 94.0000 80.0000 33.6585
2.4500 94.0000 82.0000 33.5353
2.4500 94.0000 84.0000 33.4048
2.4500 94.0000 86.0000 33.2733
2.4500 94.0000 88.0000 33.1427
2.4500 94.0000 90.0000 33.0101
2.4500 94.0000 92.0000 32.8696
2.4500 94.0000 94.0000 32.7136
2.4500 94.0000 96.0000 32.5344
2.4500 94.0000 98.0000 32.3261
2.4500 94.0000 100.0000 32.0859
2.4500 94.0000 102.0000 31.8154
2.4500 94.0000 104.0000 31.5206
2.4500 94.0000 106.0000 31.2118
2.4500 94.0000 108.0000 30.9017
2.4500 94.0000 110.0000 30.6029
2.4500 94.0000 112.0000 30.3239
2.4500 94.0000 114.0000 30.0661
2.4500 94.0000 116.0000 29.8212
2.4500 94.0000 118.0000 29.5719
2.4500 94.0000 120.0000 29.2948
2.4500 94.0000 122.0000 28.9645
2.4500 94.0000 124.0000 28.5585
2.4500 94.0000 126.0000 28.0605
2.4500 94.0000 128.0000 27.4643
2.4500 94.0000 130.0000 26.7765
2.4500 94.0000 132.0000 26.0203
2.4500 94.0000 134.0000 25.2380
2.4500 94.0000 136.0000 24.4899
2.4500 94.0000 138.0000 23.8444
2.4500 94.0000 140.0000 23.3577
2.4500 94.0000 142.0000 23.0520
2.4500 94.0000 144.0000 22.9106
2.4500 94.0000 146.0000 22.8933
2.4500 94.0000 148.0000 22.9580
2.4500 94.0000 150.0000 23.0727
2.4500 94.0000 152.0000 23.2140
2.4500 94.0000 154.0000 23.3605
2.4500 94.0000 156.0000 23.4863
2.4500 94.0000 158.0000 23.5602
2.4500 94.0000 160.0000 23.5501
2.4500 94.0000 162.0000 23.4271
2.4500 94.0000 164.0000 23.1707
2.4500 94.0000 166.0000 22.7727
2.4500 94.0000 168.0000 22.2417
2.4500 94.0000 170.0000 21.6113
2.4500 94.0000 172.0000 20.9495
2.4500 94.0000 174.0000 20.3615
2.4500 94.0000 176.0000 19.9668
2.4500 94.0000 178.0000 19.8412
2.4500 94.0000 180.0000 19.9636
disp(theta_raw)
21.8014
11.3099
7.5946
5.7106
4.5739
3.8141
3.2705
2.8624
2.5448
2.2906
2.0826
1.9092
1.7624
1.6366
1.5275
1.4321
1.3479
1.2730
1.2060
1.1458
In this case the distances (86, 88, 90, etc.) are in column 2 and the angles are in column 3 (as opposed to the example A matrix where they were column 1 and 2, respectively). I notice you changed 1 to 2 in the call to unique(); that's good, but you also need to change 2 to 3 in the get_rows_near() function. Making that change, it seems to work as expected:
[~,~,jj] = unique(remote_gain_value_specified(:,2),'stable');
result = splitapply(@(x)get_rows_near(x,theta_raw(:).'),remote_gain_value_specified,jj);
result = vertcat(result{:});
disp(result);
2.4500 86.0000 22.0000 21.2927
2.4500 86.0000 12.0000 19.9182
2.4500 86.0000 8.0000 20.5718
2.4500 86.0000 6.0000 20.7968
2.4500 86.0000 4.0000 21.0005
2.4500 86.0000 4.0000 21.0005
2.4500 86.0000 4.0000 21.0005
2.4500 86.0000 2.0000 21.2171
2.4500 86.0000 2.0000 21.2171
2.4500 86.0000 2.0000 21.2171
2.4500 86.0000 2.0000 21.2171
2.4500 86.0000 2.0000 21.2171
2.4500 86.0000 2.0000 21.2171
2.4500 86.0000 2.0000 21.2171
2.4500 86.0000 2.0000 21.2171
2.4500 86.0000 2.0000 21.2171
2.4500 86.0000 2.0000 21.2171
2.4500 86.0000 2.0000 21.2171
2.4500 86.0000 2.0000 21.2171
2.4500 86.0000 2.0000 21.2171
2.4500 88.0000 22.0000 21.0880
2.4500 88.0000 12.0000 19.9140
2.4500 88.0000 8.0000 20.6171
2.4500 88.0000 6.0000 20.8388
2.4500 88.0000 4.0000 21.0294
2.4500 88.0000 4.0000 21.0294
2.4500 88.0000 4.0000 21.0294
2.4500 88.0000 2.0000 21.2296
2.4500 88.0000 2.0000 21.2296
2.4500 88.0000 2.0000 21.2296
2.4500 88.0000 2.0000 21.2296
2.4500 88.0000 2.0000 21.2296
2.4500 88.0000 2.0000 21.2296
2.4500 88.0000 2.0000 21.2296
2.4500 88.0000 2.0000 21.2296
2.4500 88.0000 2.0000 21.2296
2.4500 88.0000 2.0000 21.2296
2.4500 88.0000 2.0000 21.2296
2.4500 88.0000 2.0000 21.2296
2.4500 88.0000 2.0000 21.2296
2.4500 90.0000 22.0000 20.8823
2.4500 90.0000 12.0000 19.9229
2.4500 90.0000 8.0000 20.6643
2.4500 90.0000 6.0000 20.8810
2.4500 90.0000 4.0000 21.0581
2.4500 90.0000 4.0000 21.0581
2.4500 90.0000 4.0000 21.0581
2.4500 90.0000 2.0000 21.2422
2.4500 90.0000 2.0000 21.2422
2.4500 90.0000 2.0000 21.2422
2.4500 90.0000 2.0000 21.2422
2.4500 90.0000 2.0000 21.2422
2.4500 90.0000 2.0000 21.2422
2.4500 90.0000 2.0000 21.2422
2.4500 90.0000 2.0000 21.2422
2.4500 90.0000 2.0000 21.2422
2.4500 90.0000 2.0000 21.2422
2.4500 90.0000 2.0000 21.2422
2.4500 90.0000 2.0000 21.2422
2.4500 90.0000 2.0000 21.2422
2.4500 92.0000 22.0000 20.6637
2.4500 92.0000 12.0000 19.9424
2.4500 92.0000 8.0000 20.7130
2.4500 92.0000 6.0000 20.9232
2.4500 92.0000 4.0000 21.0866
2.4500 92.0000 4.0000 21.0866
2.4500 92.0000 4.0000 21.0866
2.4500 92.0000 2.0000 21.2548
2.4500 92.0000 2.0000 21.2548
2.4500 92.0000 2.0000 21.2548
2.4500 92.0000 2.0000 21.2548
2.4500 92.0000 2.0000 21.2548
2.4500 92.0000 2.0000 21.2548
2.4500 92.0000 2.0000 21.2548
2.4500 92.0000 2.0000 21.2548
2.4500 92.0000 2.0000 21.2548
2.4500 92.0000 2.0000 21.2548
2.4500 92.0000 2.0000 21.2548
2.4500 92.0000 2.0000 21.2548
2.4500 92.0000 2.0000 21.2548
2.4500 94.0000 22.0000 20.4231
2.4500 94.0000 12.0000 19.9702
2.4500 94.0000 8.0000 20.7624
2.4500 94.0000 6.0000 20.9652
2.4500 94.0000 4.0000 21.1148
2.4500 94.0000 4.0000 21.1148
2.4500 94.0000 4.0000 21.1148
2.4500 94.0000 2.0000 21.2673
2.4500 94.0000 2.0000 21.2673
2.4500 94.0000 2.0000 21.2673
2.4500 94.0000 2.0000 21.2673
2.4500 94.0000 2.0000 21.2673
2.4500 94.0000 2.0000 21.2673
2.4500 94.0000 2.0000 21.2673
2.4500 94.0000 2.0000 21.2673
2.4500 94.0000 2.0000 21.2673
2.4500 94.0000 2.0000 21.2673
2.4500 94.0000 2.0000 21.2673
2.4500 94.0000 2.0000 21.2673
2.4500 94.0000 2.0000 21.2673
%% Function
function out = get_rows_near(x,theta_raw)
[~,idx] = min(abs(x(:,3)-theta_raw),[],1);
out = {x(idx,:)};
end
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
アジア太平洋地域
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)