- #1
Keithwkc
- 1
- 0
Greetings,
I have been trying to get rid of a bunch scattered data points whose x coordinates lie outside a distance from the x coordinates of a curve. These outlying x coordinates need to be changed into NaN's. The trouble is that a lot of these outlying points have the same y-axis values and my code has only been able to remove one of each set of data points with the same y-axis value.
For example:
scattered point x-coord= [1 2 3 4 5 6 7 8 9 10]
scattered point y-coord= [2 2 10 10 2 4 4 4 5 5 ]
curve x-coord= [0 1 2 3 4 5 6 7 8 9]
curve y-coord= [0 1 2 3 4 5 6 7 8 9]
Need to change elements of scattered point x-coord lying more than 2 units away from curve x-coord into NaN's, i.e.
desired scattered output x-coord= [1 2 NaN NaN NaN 6 NaN NaN NaN NaN]
Any advice on to obtain the above "desired scattered output x-coord" will be greatly appreciated.
I have tried using xi(find(abs(xi-xj)>=1))=NaN and even a for loop to run through each and every individual element
for i=1:n %n=number of elements in the vector scattered output coord
index=find(sx==cx(i)) % sx= scattered x-coord and cx= curve x-coord
sx(find(abs(sx(index)-cy(i))))=NaN % cy= curve y coord
end
but have not been successful in obtaining the desired result.
Thank you in advance for your help.
I have been trying to get rid of a bunch scattered data points whose x coordinates lie outside a distance from the x coordinates of a curve. These outlying x coordinates need to be changed into NaN's. The trouble is that a lot of these outlying points have the same y-axis values and my code has only been able to remove one of each set of data points with the same y-axis value.
For example:
scattered point x-coord= [1 2 3 4 5 6 7 8 9 10]
scattered point y-coord= [2 2 10 10 2 4 4 4 5 5 ]
curve x-coord= [0 1 2 3 4 5 6 7 8 9]
curve y-coord= [0 1 2 3 4 5 6 7 8 9]
Need to change elements of scattered point x-coord lying more than 2 units away from curve x-coord into NaN's, i.e.
desired scattered output x-coord= [1 2 NaN NaN NaN 6 NaN NaN NaN NaN]
Any advice on to obtain the above "desired scattered output x-coord" will be greatly appreciated.
I have tried using xi(find(abs(xi-xj)>=1))=NaN and even a for loop to run through each and every individual element
for i=1:n %n=number of elements in the vector scattered output coord
index=find(sx==cx(i)) % sx= scattered x-coord and cx= curve x-coord
sx(find(abs(sx(index)-cy(i))))=NaN % cy= curve y coord
end
but have not been successful in obtaining the desired result.
Thank you in advance for your help.