フィルターのクリア

Finding Minimum Distance Between Points to Find Indexed Variable

3 ビュー (過去 30 日間)
Jonathan Pinko
Jonathan Pinko 2020 年 3 月 12 日
コメント済み: Jonathan Pinko 2020 年 3 月 24 日
Hi All,
Two matrices, one here with size 1251x3:
dtamatrix = [xFe54t(:),Fo(:),DeltaFe56(:)];
And another one here, with size 4x1:
Felimitmatrix = [Foyqlimit(:)]
First, I want to find which values of Fo each of my Foyqlimit values are closest to, generating four values of Fo. Then, I want my code to read the specific xFe54t values that correspond with these four values of Fo, generating a 4x1 column vector of xFe54t values.
Can anyone provide any insight as to how to do this?
Thanks,
Joanthan
  2 件のコメント
darova
darova 2020 年 3 月 12 日
Too much explanations. Couldn't handle them
Can you make a simple drawing or something?
Jonathan Pinko
Jonathan Pinko 2020 年 3 月 13 日
A drawing would be tough, but I'll try to simplify things. I've changed things a little.
Two matrices, one here with size 1251x3:
dtamatrix = [xFe54t(:),Fo(:),DeltaFe56(:)];
And another one here, with size 4x1:
Felimitmatrix = [Foyqlimit(:)]
First, I want to find which values of Fo each of my Foyqlimit values are closest to, generating four values of Fo. Then, I want my code to read the specific xFe54t values that correspond with these four values of Fo, generating a 4x1 column vector of xFe54t values.
How could I do this?
Thanks for responding.

サインインしてコメントする。

採用された回答

Turlough Hughes
Turlough Hughes 2020 年 3 月 13 日
編集済み: Turlough Hughes 2020 年 3 月 13 日
If you don't have the statistics and machine learning toolbox you can do the following:
[~,idx] = min(abs(dtamatrix(:,2) - Felimitmatrix.')); % for 2016b and later
and alternatively for versions prior to 2016b
[~,idx] = min(abs(bsxfun(@minus,dtamatrix(:,2),Felimitmatrix.'))); % before 2016b
Results:
xFe54t_Flim = dtamatrix(idx,1);
  1 件のコメント
Jonathan Pinko
Jonathan Pinko 2020 年 3 月 24 日
I apologize for the late reply, but this worked great.
Thank you!

サインインしてコメントする。

その他の回答 (1 件)

darova
darova 2020 年 3 月 13 日
Use pdist2 to find closest points
D = pdist2(Fo(:),Foyqlimit(:)); % every combination (Matrix 1251x4)
[~,ix] = min(D); % closest indices
xFe54t(ix) % values you want

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by