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

1 view (last 30 days)
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?

Accepted Answer

Sam
Sam on 16 Nov 2017
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))

More Answers (0)

Categories

Find more on Interpolation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!