I need to know how to organize a find statement into a set order with characters instead of it's number's. I want information to come out like below.

1 回表示 (過去 30 日間)
A=[18 33 31 34 15 37 10.5 48 50 38 35 39 42 33 31 1 5 9 13 11 27 35 -1 46 22 6 19 36];
volt=round(A);
%newscrip below
function [fruit_fin]=Program05b(volt)
B=[1:1:28]
O=[find(volt>=31 & volt<=40,28)]
G=[find(volt>=21 & volt<=30,28)]
P=[find(volt>=11 & volt<=20,28)]
A=[find(volt>=0 & volt<=10,28)]
U=[find(volt<0 | 40<volt,28)]
fruit_fin=[O,P,G,A,U]
end
% anwers % I know how to get it into a table.
18 P
33 O
31 O
34 O
15 P
37 O
10.5 P
48 U
50 U
38 O
35 O
39 O
42 U
33 O
31 O
1 A
5 A
9 A
13 P
11 P
27 G
35 O
-1 U
46 U
22 G
6 A
19 P
36 O

採用された回答

Steven Lord
Steven Lord 2019 年 3 月 13 日
編集済み: Steven Lord 2019 年 3 月 13 日
discretize your data.
A=[18 33 31 34 15 37 10.5 48 50 38 35 39 42 33 ...
31 1 5 9 13 11 27 35 -1 46 22 6 19 36];
volt=round(A);
edges = [-Inf 0 11 21 31 41 Inf];
bins = {'U', 'A', 'P', 'G', 'O', 'U'};
results = discretize(volt, edges, bins);
Elements in volt in the range [-Inf, 0) will map to 'U' in results. I tried to indicate that with spacing in the code above, where U is between -Inf and 0.
Elements in volt in the range [0, 11) will map to 'A' in results. The other bins behave similarly until you reach the last one.
The last bin is special. Elements in volt in the range [41, Inf] will map to 'U' in results. The last bin contains both its endpoints, not just the left one.

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by