how to calculate the distance between 2 matrix (without counting the number of 255)?

1 回表示 (過去 30 日間)
Mei Synn Tan
Mei Synn Tan 2017 年 5 月 5 日
回答済み: KSSV 2017 年 5 月 5 日
A = 255 0 135
91 255 255
3 21 255
B = 11 0 135
91 21 97
3 21 218
E_distance = sqrt(sum((A-B).^2)); E_distance = 375
But I want to get the E_distance = 0. When the number is 255, don't need to calculate the distance between 2 matrix (direct skip). A & B become:
A = 0 135
91
3 21
B = 0 135
91
3 21
When apply E_distance can get 0.
How to do? Please help me. Thanks

採用された回答

KSSV
KSSV 2017 年 5 月 5 日
A = [255 0 135
91 255 255
3 21 255] ;
B = [11 0 135
91 21 97
3 21 218] ;
A0 = A ;
A(A0==255) = [] ;
B(A0==255) = [] ;
E_distance = sqrt(sum((A-B).^2));

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by