# 1D fit on a surface in matlab

I have a problem fitting a $N\times N$ ($32\times 32$ in this case) matrix in Matlab.

Here is the deal

I have this image, and I want to create 1 dimensional fit between the points and then be able to interpolate it in order to make it smoother.

Does anyone have any idea if that can be done?

• Welcome to SciComp.SE. It is not clear to me what you want to do. You have a matrix with real numbers and you want to compute a 1D interpolation of these values?? That sounds odd. Unless, and judging for your image, you wan to find an interpolation function for the "different" points in your matrix, i.e., points that are different from the background. Jul 8 '15 at 18:29
• You are almost right. Ok so essentially what i need is if you imagine a curve just passing trough that pretzel kind of shape. Now the thing is the shape can be arbitrary but it is always going to be continuous. So it can be a circle or a spiral or something else. So as I said imagine you play connect the dots and you connect only the ones which you can see right now. Then I have a way of using the line segments to do what I need. But I need the curve so I can use it as a sort of trajectory.
– Mike
Jul 8 '15 at 20:13
• P.S. The whole idea is that afterwards I am going to know which elements of the matrix I need and as I have a way of filling the data I will be able to generate the same shape with higher precision.
– Mike
Jul 8 '15 at 20:20
• You should edit your question then. You're not saying that in the text. In essence, you don't even have an $N\times N$ matrix. Jul 8 '15 at 20:55
• Uh sorry I might have made it a bit unclear. But about the matrix - the fit will always be performed on a square matrix
– Mike
Jul 8 '15 at 21:04