|
From: Thomas W. <we...@nu...> - 2005-03-02 16:06:37
Attachments:
interp2.m.patch
|
Hi, I attach a patch against interp2.m: changes: * new handling of input arguments - I couldn't quite understand the old one * correct handling of non-monotonic vectors xi and yi and correct handling of out of border values * unit tests added Please cc me on replies (Sourceforge is quite slow with my subscription). Regards Thomas |
|
From: Paul K. <pki...@us...> - 2005-03-03 04:54:46
Attachments:
interp2.m
|
Thomas, I rewrote much of the argument processing and made use of lookup() to simplify the code. I've posted the changes back to CVS. I'm attaching the file here for your convenience. Please let me know if you have any problems with it. All your tests pass the new code. Thanks, - Paul On Mar 2, 2005, at 11:06 AM, Thomas Weber wrote: > Hi, > > I attach a patch against interp2.m: > > changes: > * new handling of input arguments - I couldn't quite understand the old > one > * correct handling of non-monotonic vectors xi and yi and correct > handling of out of border values > * unit tests added > > Please cc me on replies (Sourceforge is quite slow with my > subscription). |
|
From: Thomas W. <we...@nu...> - 2005-03-03 08:21:25
|
Paul, > I rewrote much of the argument processing and made use of > lookup() to simplify the code. Thanks - I feel somewhat stupid for my long code. > Please let me know if you have any problems with it. Actually yes, I have problems with it. They are not due to your (or my) changes, but I consider this function flawed. I'm currently in the following situation: x, y: vectors of length ~200 Z: matrix of 200^2 xi, yi: vectors of length ~16000 Now, interp2 tries a meshgrid(xi,yi), which results in 'out of memory'. However, I'm only interested in the interpolated values at [xi(i), yi(i)], not at the complete grid one can construct with these vectors. Therefore, I'm thinking about changing the function to return an interpolated vector at the positions of (xi,yi) if they are vectors; if the user wants a complete grid, he can still do an [XI, YI] = meshgrid(xi,yi) before and hand the matrices to interp2. Please note that this will break compatibility with Matlab (which shows the same 'out of memory' behaviour). Any suggestions? Regards Thomas |
|
From: Paul K. <pki...@us...> - 2005-03-03 13:04:21
|
On Mar 3, 2005, at 3:21 AM, Thomas Weber wrote: > Paul, >> Please let me know if you have any problems with it. > Actually yes, I have problems with it. They are not due to your (or my) > changes, but I consider this function flawed. > > I'm currently in the following situation: > x, y: vectors of length ~200 > Z: matrix of 200^2 > xi, yi: vectors of length ~16000 > > Now, interp2 tries a meshgrid(xi,yi), which results in 'out of memory'. > However, I'm only interested in the interpolated values at > [xi(i), yi(i)], not at the complete grid one can construct with these > vectors. > > Therefore, I'm thinking about changing the function to return an > interpolated vector at the positions of (xi,yi) if they are vectors; > if > the user wants a complete grid, he can still do an > [XI, YI] = meshgrid(xi,yi) before and hand the matrices to interp2. > > Please note that this will break compatibility with Matlab (which shows > the same 'out of memory' behaviour). > > Any suggestions? > Please don't break compatibility. You can make a new function which doesn't do an implicit meshgrid on the xi,yi arguments and call it from interp2. I don't really like that solution, but I can't think of a nice way to mark which form of xi,yi you want in the parameter list. - Paul |