[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Re: Filling the gaps in data arrays

**From**: |
Przemek Klosowski |

**Subject**: |
Re: Filling the gaps in data arrays |

**Date**: |
Thu, 12 Jul 2018 10:59:30 -0400 |

**User-agent**: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 |

On 07/12/2018 04:36 AM, Mat086 wrote:

dx = x(2)-x(1);
Y = zeros(1,length([min(x):dx:max(x)]));
X = [min(x):dx:max(x)];
for k=1:length(x)
indx = find(X==x(k));
Y(k) = y(index);
endfor
plot(x,y,'b-'); hold on; plot(X,Y,'-o');

you meanĀ Y(k) = y(indx); , right?

`And no, it won't work in Matlab either because you are doing exact
``floating point comparisons on calculated values, so any roundoff will
``trip you up---check for yourself, X==X(3) returns matches, but X==x(3)
``probably doesn't.
`

`You said that "In order to analyze such kind of data with another
``software I need to create X and Y vectors without holes". What is
``exactly the assumption there? Is the original dataset sampled on a
``regular grid, and the non-zero values are dropped?
`

`It seems to me that the best solution for you would be to interpolate
``your data onto a regular grid, perhaps like this:
`
dx=x(2)-x(1);
plot(x,y,'x',X=min(x):dx:max(x),interp1(x,y,X))