matrix, value, comparing

3 visualizzazioni (ultimi 30 giorni)
Nicle Davidson
Nicle Davidson il 11 Nov 2021
Commentato: Star Strider il 12 Nov 2021
I would like to find out if each line with its six values in matrix U has closer values to the line of the six values in matrix MA or to the line of values in matrix TA? (by the way these are time values)so if I find f.ex. line one in U is more like the line in MA, so it means that the happening is the same as happening in MA.
MA =
0 4.4710 8.8828 13.6977 17.7027 21.7184
TA =
0 5.0490 9.3733 13.6038 17.2513 20.5759
and
U =
0 3.4874 8.3723 12.8400 15.7461 21.0089
0 3.6776 8.4321 12.9606 15.7762 21.0557
0 5.5318 8.2832 12.8565 17.5710 20.9515
0 5.6120 8.4264 12.8430 17.5558 20.9401
0 5.6243 10.0483 12.8954 17.7006 22.3821
0 5.5102 10.0276 12.8021 17.5814 22.2412
0 3.1558 7.6719 12.2234 15.1850 19.9813
0 3.1794 7.6655 12.3352 15.4489 20.0210
0 4.7771 7.5656 12.2135 17.4471 19.8625
0 4.7598 7.5804 12.2065 17.5210 20.0173
Is it possible? how can one do this?
*PS: I have heard that knnsearch might could help, but have no idea how it does. maybe someone could show?
https://se.mathworks.com/help/stats/exhaustivesearcher.knnsearch.html

Risposta accettata

Star Strider
Star Strider il 11 Nov 2021
One option is pdist2
MA = [0 4.4710 8.8828 13.6977 17.7027 21.7184];
TA = [0 5.0490 9.3733 13.6038 17.2513 20.5759];
U = [0 3.4874 8.3723 12.8400 15.7461 21.0089
0 3.6776 8.4321 12.9606 15.7762 21.0557
0 5.5318 8.2832 12.8565 17.5710 20.9515
0 5.6120 8.4264 12.8430 17.5558 20.9401
0 5.6243 10.0483 12.8954 17.7006 22.3821
0 5.5102 10.0276 12.8021 17.5814 22.2412
0 3.1558 7.6719 12.2234 15.1850 19.9813
0 3.1794 7.6655 12.3352 15.4489 20.0210
0 4.7771 7.5656 12.2135 17.4471 19.8625
0 4.7598 7.5804 12.2065 17.5210 20.0173];
[DMA,IMA] = pdist2(U,MA, 'euclidean', 'Smallest',1)
DMA = 1.6727
IMA = 3
[DTA,ITA] = pdist2(U,TA, 'euclidean', 'Smallest',1)
DTA = 1.4205
ITA = 4
So here the thiird row of ‘U’ is closest to ‘MA’ and the fourth row closeest to ‘TA’.
.
  12 Commenti
Nicle Davidson
Nicle Davidson il 12 Nov 2021
@Star Strider you are a star!
Star Strider
Star Strider il 12 Nov 2021
Thank you!!!
.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Downloads in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by