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

1 Ansicht (letzte 30 Tage)
Sam
Sam am 16 Nov. 2017
Beantwortet: Sam am 16 Nov. 2017
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?

Akzeptierte Antwort

Sam
Sam am 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))

Weitere Antworten (0)

Kategorien

Mehr zu Interpolation finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by