find the element of an array
find the element of an array
(OP)
Hi,
I'm looking for the simplest way to find the index of the element of a vector that is closer to a given value.
Suppose the vector is f[i:=i^2 and the value V:40 .
The solution is i=6 as 6^2=36. How to find that i value? Do there is any function doing that? Do you know any trick using the programming?
See attachment for an attempt to solve it (not working.
regards and thanks in advance
I'm looking for the simplest way to find the index of the element of a vector that is closer to a given value.
Suppose the vector is f[i:=i^2 and the value V:40 .
The solution is i=6 as 6^2=36. How to find that i value? Do there is any function doing that? Do you know any trick using the programming?
See attachment for an attempt to solve it (not working.
regards and thanks in advance





RE: find the element of an array
Error:= vectorize abs(f-v.LO)
Index:= match(min(Error),Error)
Vectorize is a function on the matrix toolbar.
Peter
RE: find the element of an array
However, the result is a vector itself. How to convert it to a number?
Thanks again!
RE: find the element of an array
Thanks again.