How to work out the # of the term in a vector by searching with a value.

1 回表示 (過去 30 日間)
Sam
Sam 2017 年 11 月 16 日
回答済み: Sam 2017 年 11 月 16 日
I have a vector which contains the roots of a polynomial equation. They're in a column vector called root so I can call on them i.e. z(1),z(2) etc.
As my overall function is to interpolate values until it finds a root, I find the error by using abs(min(root-x(n))) where x(n) is the calculated value. By using the min function it works out the error to the root it's interpolating to. I know which root its converging to, but I need to work out which # in the column vector that root is located.
E.g. converges to 1 where column vector is [2 ; 4 ; 3 ; 1], I would need the value to give 4. Is there anyway I can search through a column vector for a value, and if so is there anyway I can put within a certain confidence interval if it's slightly off?

採用された回答

Sam
Sam 2017 年 11 月 16 日
Think I found an answer from here (https://uk.mathworks.com/matlabcentral/answers/4298-find-an-element-of-a-matrix-equal-to-a-constant)
So I can just use I = find(root==(root that I found))

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by