I understand that you are trying to reconstruct the polynomial form of a multi-dimensional spline at each interval using MATLAB’s “csaps” function.
When working with multi-dimensional splines, we need to extract and assign the coefficients from “pp.coefs” to their respective polynomial terms.
The approach would be as follows:
- Use “csaps” to generate a 3-dimensional cubic spline.
- Extract coefficients using “pp.coefs”.
- Iterate through each interval, reconstructing and displaying the polynomial terms using “syms”.
This will make sure that the correct polynomial form for each interval is obtained from the “csaps” output.
Below is the MATLAB code for the same:
x = {-1:1:1, -1:1:1, -1:1:1};
[xx, yy, zz] = ndgrid(x{1}, x{2}, x{3});
v = 2*xx.^2 + 4*yy.^2 - 3*xx.*zz;
fprintf('Interval %d:\n', i);
poly = coefs(i, 1)*X^3 + coefs(i, 2)*Y^3 + coefs(i, 3)*Z^3 + ...
coefs(i, 4)*X^2 + coefs(i, 5)*Y^2 + coefs(i, 6)*Z^2 + ...
coefs(i, 7)*X*Y + coefs(i, 8)*X*Z + coefs(i, 9)*Y*Z + ...
coefs(i, 10)*X + coefs(i, 11)*Y + coefs(i, 12)*Z + coefs(i, 13);
fprintf('Polynomial for interval %d:\n', i);
For further reference on “csaps”, kindly refer to the following documentation:
I hope this helps!
(As can be seen in the screenshot below, the error has been resolved)