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

1 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Interpolation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by