0

I know things about linear/quadratic fittings etc. I'm just wondering, if i know a set of data for value e.g. z=[-2.563 -0.1932 -0.1502 -0.1102 -0.836 -0.5234] and l=[1 2 3 4 5 6] m=[6 5 4 3 2 1] I want to write out a function of z in terms of l and m. How would i be able to start this? Many thanks in advance!

joriki
  • 238,052

1 Answers1

0

The values of $(l,m)$ all lie on one line, so this isn't actually a two-dimensional problem; you can just do a one-dimensional fit with respect to either $l$ or $m$. Then if you want to evaluate the function at an arbitrary point $(l,m)$, just project it onto the line $l+m=7$ and evaluate the fitted function there.

[Edit in response to comment:]

You only have function values on a single line. The best you can do if you want to approximate a function value off the line is to take the function value at the closest point on the line, which is the orthogonal projection of the point onto the line. The orthogonal projection of the point $(l,m)$ onto the line $l+m=7$ is $((7+l-m)/2,(7+m-l)/2)$, so you get the approximation by evaluating a function fitted with respect to $l$ at $(7+l-m)/2$ or evaluating a function fitted with respect to $m$ at $(7+m-l)/2$.

joriki
  • 238,052
  • could you please explain more about projection part? I don't quite get that. – chenwan Sep 12 '12 at 11:24
  • my situation is as follows, I have a matrix of z values depending on the l and m value, l always starts from 1 to some number n while m goes from n till 1. for example, with l= 1 2 3 4 5 ,m=5 4 3 2 1 and this z value will be a length of 5 vector which is totally different as the case with l=1 2 3 4 5 6 7 and m=7 6 5 4 3 2 1. So i couldn't really just use either l or m as the dependent variable to form the function of z. In that case, i wouldn't use that function to find z for all cases. Thank you anyway! – chenwan Sep 12 '12 at 11:24
  • How do you mean, you couldn't really use either $l$ or $m$ as the dependent variable? What keeps you from doing it? – joriki Sep 12 '12 at 11:32
  • if i use l as dependent variable in first case, when l is 1, it gives a z value according to the function which is true as my original value of z. However, we can't use that l=1 to find z for another case. Unless, i have z in terms of l and m the same time. – chenwan Sep 12 '12 at 11:38
  • are you saying i find a fit of z in terms of 7+m-l/2? – chenwan Sep 12 '12 at 11:38
  • In case you mean $(7+m-l)/2$, yes, you could put it that way. – joriki Sep 12 '12 at 11:45
  • So i should put 7 as another dependent variable as the m+l changes for finding different set of z. Thank you! – chenwan Sep 12 '12 at 11:52
  • @chenwan: I don't know what you mean by putting $7$ (a constant) as another dependent variable. It sounds like the opposite of what I meant. What I was trying to say is that you can reduce the problem by considering the function only on the line $l+m=7$ and regarding it there as a function of a single variable ($l$, $m$, $(7+m-l)/2$ or whatever other linear combination of $l$ and $m$ you prefer), not introduce yet another variable. – joriki Sep 12 '12 at 11:58
  • If you want to make this more explicit, you might as well say that you consider the function as a function of $l-m$; no need to add $7$ or divide by $2$, since this can be absorbed into the interpolating function. – joriki Sep 12 '12 at 12:01
  • Let me explain this more, i have results for z=[] with when x=[],y=[] which are equal length vectors. And i want to find z as a function of x and y , if i use x as the independent variable, e.g. x=[1 2 3 4 5], y=[5 4 3 2 1],z=exp(x). However, there is the problem, i have not only just one vector of z but z set up as the matrix value. in another case where x=[1 2 3 4 5 6] but with y=[6 5 4 3 2 1]. If we use the same function we defined before z=exp(x), we wouldn't be the same value for z in this case. That's the key problem here. – chenwan Sep 12 '12 at 12:12
  • @chenwan: What do you mean by "$z$ set zp as the matrix value"? And why would you want to use the same function for a different set of data? Are the data sets somehow related? Please try to give a systematic presentation of the problem all in one piece; this is an inefficient way of discussing it. – joriki Sep 12 '12 at 12:46
  • z as a matrix form i mean for each x,y vector, there is different corresponding z vector. For simplicity. if x=[1 2 3],y=[3 2 1], z=[a b c]. while another case is x=[1 2 3 4] , y=[ 4 3 2 1], and z=[ d e f g]. Note these two z are totally different. But i need to combine those to find a suitable function for z in terms of x, y . So it must depending on both x and y value. – chenwan Sep 12 '12 at 13:15
  • @chenwan: It's not clear to me what you mean when you say on the one hand that "these two $z$ are totally different" and on the other hand that you "need to combine those to find a suitable function for $z$ in terms of $x,y$". Are you saying that you want a single function $z(x,y)$ that interpolates all these function values, both the ones for $x=[1 2 3]$, $y=[3 2 1]$ and the ones for $x=[1 2 3 4]$, $y=[4 3 2 1]$? If so, why didn't you say that in the original question? In that case, you should fix the question to reflect what you actually intended to ask about. – joriki Sep 12 '12 at 13:25