how can I compute distances:

3 visualizzazioni (ultimi 30 giorni)
Robin Kaiser
Robin Kaiser il 27 Gen 2020
Commentato: Walter Roberson il 28 Gen 2020
how can I compute distances:
I have a code which was running in matlab 2016:
Nat=1000;
pos=(rand(3, Nat)-0.5);
kr=dist(pos)+eye(Nat);
In my new matlab version (Matlab 2019), it seems to require an additional toolbox?
yours
Robin

Risposta accettata

Robin Kaiser
Robin Kaiser il 28 Gen 2020
Thank you for your fast feedback. I tried and get the following reply:
'pdist' requires Statistics and Machine Learning Toolbox.
yours
Robin
  1 Commento
Walter Roberson
Walter Roberson il 28 Gen 2020
kr = squeeze(sum((pos - permute(pos, [1 3 2])).^2,1)) + eye(NAT);

Accedi per commentare.

Più risposte (3)

Fangjun Jiang
Fangjun Jiang il 27 Gen 2020
Run the code and then run "license inuse". Only MATLAB is needed.
  2 Commenti
Robin Kaiser
Robin Kaiser il 28 Gen 2020
after "license inuse" I get
"matlab" as answer, but dist(pos) still does not work. Is this a backward incompatibilty?
Walter Roberson
Walter Roberson il 28 Gen 2020
It is not a backward incompatibility. dist() was never part of basic MATLAB. You probably had some third-party dist() function.

Accedi per commentare.


Walter Roberson
Walter Roberson il 27 Gen 2020
dist() is part of the Deep Learning Toolbox
  2 Commenti
Robin Kaiser
Robin Kaiser il 28 Gen 2020
I see that
'dist' requires one of the following:
Deep Learning Toolbox
Navigation Toolbox
Robotics System Toolbox
Sensor Fusion and Tracking Toolbox
But I did not have those in my previous matlab version. So this seems to be a backward incompatibility?
Walter Roberson
Walter Roberson il 28 Gen 2020
No, it implies you used a third-party function before.
If you want to use basic MATLAB, then
kr = squareform(pdist(pos.')) + eye(Nat);

Accedi per commentare.


Robin Kaiser
Robin Kaiser il 28 Gen 2020
Thank you: this works
yours
Robin

Categorie

Scopri di più su Deep Learning Toolbox in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by