I'm struggling to find a solution to this problem since the last week and still got no result.
I have a 3d spline in matlab, necessarily defined (I can't change the representation) with the spap2 command, and I need to evaluate the spline itself given two coordinates (say x and y). I tried to use the fnval command with different sintaxes but with no success.
Example: I'd like to get the z at x=26, y=120 with the spline defined with
x=[13 56 90 67 89 43];
y=[112 156 136 144 144 128];
z=[63 95 48 78 77 15];
sp = spap2(4,4,1:length(x),[x; y; z]);
Could anyone help me? Thank you very much!
A spline is an approximation. It does not need to go through the coordinates (x=26,y=120) at all. There is no immediate definition of what z value would be reasonable for these (x, y) values.
Your x values (independent values) are 1:length(x)
and the output (dependent values) is [x;y;z]
.
For example fnval(sp, 1.5)
gives a reasonable output.