您好我正在尝试在MATLAB上执行此操作
A =
64 2 3 61 60 6 7 57
9 55 54 12 13 51 50 16
17 47 46 20 21 43 42 24
40 26 27 37 36 30 31 33
32 34 35 29 28 38 39 25
41 23 22 44 45 19 18 48
49 15 14 52 53 11 10 56
8 58 59 5 4 62 63 1
我想根据F
从A中选择值F =
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
-1 -1 -1 -1 -1 -1 -1 -1
0 0 0 0 0 0 0 0
-1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1
我想要这个输出
u =
40 26 27 37 36 30 31 33
41 23 22 44 45 19 18 48
49 15 14 52 53 11 10 56
8 58 59 5 4 62 63 1
这意味着我希望矩阵中的所有值都对应于'-1'。我试过你= A(F == - 1)......但它给了我一个包含所有这些值的列:
u =
40
41
49
8
26
23
15
58
27
22
14
59
37
44
52
5
36
45
53
4
30
19
11
62
31
18
10
63
33
48
56
1
答案 0 :(得分:0)
这样做: -
with
inputs ( seq, str ) as (
select 1, 'alpha:"123.k"..."myField":{"$bigdec":"1.23"} and others'
from dual
),
nbr ( seq, n ) as (
select seq,
regexp_substr(str, '"myField":{"\$bigdec":"(\d+\.?\d*)"}', 1, 1, null, 1)
from inputs
),
repl ( seq, r_str ) as (
select seq, to_char( round(power(to_number(n), 3), 2), 'fm99999999.99')
from nbr
)
select i.seq, i.str,
regexp_replace(i.str, '"myField":{"\$bigdec":"\d+\.\d*"}',
'"myField":{"\$bigdec":"' || r.r_str || '"}') as repl_str
from inputs i inner join repl r on i.seq = r.seq
;
SEQ STR
---- ---------------------------------------------------------
1 alpha:"123.k"..."myField":{"$bigdec":"1.23"} and others
REPL_STR
--------------------------------------------------------
alpha:"123.k"..."myField":{"\$bigdec":"1.86"} and others
另一种解决方案: -
u=-A.*F;
u(all(u==0,2),:)=[] %Removing rows containing zeros