You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to The MATLAB users
Hi,
I have 2 vectors.
Example of vector A = [1.5 3.5 2.5 3 0.5 1 3 0.5 1.5 0.5...]
Example of vector B = [ 0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 ....]
I need a vector C where to put , for each value in vector A, its
position in vector B
I need C = [ 4 8 6 7 2 3 6 2 4 2 ]
I am doing it with a 'for' loop and 'find' operation:
for i=1:10; find(B==A(i))
end
BUT i have the following problem.
Some values at vector A are not equal to values in vector B. For
example
A(2) = 3.499999999999999 and B(8)=3.5
And the 'for' loops gives me an error.
My questions are:
Is there some way to solve the == problem?
How can I find the nearest value (not the exact one)?
Thanks in advance
cesar
Alex Frid
unread,
Jul 7, 2008, 1:29:20 AM7/7/08
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to matlab...@googlegroups.com
Hi, you can write in side the find function more complex expression like: >> find(B<A(i)+threshold & B>A(i)-threshold) where the threshold value will be your accuracy expectation.