NEED HELP ON MATRIX MANIPULATIONS
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
anshuman mishra
le 16 Déc 2019
Commenté : anshuman mishra
le 16 Déc 2019
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 commentaires
Réponse acceptée
KSSV
le 16 Déc 2019
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 ;
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Multidimensional Arrays dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!