### Rita (view profile)

on 3 Nov 2016
Latest activity Commented on by Rita

on 8 Nov 2016

### John D'Errico (view profile)

I have worked with this great function and I can't understand why this happens: If we have a vector with 100 data and some nans and run the function to get the values for nans and also dividing the data to 5 parts(5*20 each small vector has 20 data) and using the function(the nans are the same for each 20 records ) so why the results for both ways are not the same??? Thanks for any idea.

### John D'Errico (view profile)

on 3 Nov 2016
Edited by John D'Errico

### John D'Errico (view profile)

on 3 Nov 2016

Why would they be the same? You are posing two different problems. It sounds like you have reshaped the vector into a 5x20 array. On two dimensional problems, the function works in both dimensions, looking at the neighbors of a point in all directions to interpolate.
Or, did you break the vector into 5 disjoint vectors, then calling inpaint_nans 5 separate times? Even in this case, the function uses the neighbors of a point in each direction. So if a nan is at or near the break point between those segments then of course there will be a difference.
Perhaps you can give an example where you see a problem, attach the data to a comment, and show how you called it.

Rita

### Rita (view profile)

on 4 Nov 2016
Thanks John,the data is in 1D shape.and Yes I took a part the vector to 5 "disjoint vectors" The run the function for 5times separately.But I have not noticed that I have nans at the breakpoints! Thanks a lot for the clarification.
John D'Errico

### John D'Errico (view profile)

on 6 Nov 2016
Unless you can give an example where you see something different, it is difficult to know what you saw.
V = 1:20;
>> V([5 14]) = NaN;
>> inpaint_nans(V)
ans =
Columns 1 through 12
1 2 3 4 5 6 7 8 9 10 11 12
Columns 13 through 20
13 14 15 16 17 18 19 20
>> V1 = V(1:10);
>> V2 = V(11:20);
>> inpaint_nans(V1)
ans =
1 2 3 4 5 6 7 8 9 10
>> inpaint_nans(V2)
ans =
11 12 13 14 15 16 17 18 19 20
As you can see, both cases produce identical results for the NaN elements.
Rita

on 7 Nov 2016
Thanks John

### Image Analyst (view profile)

on 6 Nov 2016

FYI, starting with R2015a there is a built-in function regionfill().

Show 1 older comment
Image Analyst

### Image Analyst (view profile)

on 7 Nov 2016
Actually I was wrong - it can't be used unless you supply a 2-D image. It doesn't work with 1-D vectors.
John D'Errico

### John D'Errico (view profile)

on 7 Nov 2016
I had to modify inpaint_nans to work on vectors. It uses the same idea, but only looks along the length of the vector.
Rita

### Rita (view profile)

on 8 Nov 2016
But still inpaint_nans works well for the vectors. I have used the function for the vectors...with model number 4(metaphor)Thanks