NEED HELP ON MATRIX MANIPULATIONS
1 次查看(过去 30 天)
显示 更早的评论
Consider a matrix
A= 21 14 7 0
18 11 4 3
15 8 1 6
12 5 2 9
9 2 5 12
6 1 8 15
3 4 11 18
0 7 14 21
My objective is to reach from base value 0 to top value 0 as underlined for dynamic time warp algorithm traversal by parsing through the smallest element of each row.
A= 21 14 7 0
18 11 4 3
15 8 1 6
12 5 2 9
9 2 5 12
6 1 8 15
3 4 11 18
0 7 14 21
The cost assignment can be defined as find the smallest element in each column :
1| 21 14 7 0
0| 18 11 4 3
1| 15 8 1 6
0| 12 5 2 9
0| 9 2 5 12
1| 6 1 8 15
0| 3 4 11 18
1| 0 7 14 21
So cost= 1 0 1 0 0 1 0 1
Cost assignment concept:
assign 1 whenever there's a smallest single unique element in the row .
Assign 0 whenever no smallest element is present or when multiple smallest same elements are present in the same row or column,then first instance should be zero and next to be 1 i.e. for example
1| 20 15 10 5 0
1| 16 11 6 1 4
1| 12 7 2 3 8
0| 8 3 2 7 12
1| 4 1 6 11 16
1 | 0 5 10 15 20
0 个评论
采纳的回答
KSSV
2019-12-16
A = [ 21 14 7 0
18 11 4 3
15 8 1 6
12 5 2 9
9 2 5 12
6 1 8 15
3 4 11 18
0 7 14 21];
m = min(A,[],2) ;
cost = m == 0 | m == 1 ;
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!