Multivariate Interpolation



Hi all,

Appreciate if someone could help my following problems:

I have solved an ODE - dx = Ax + Bu
[t,X] = ode45(@fun, [t0 tf], x0);
xUn1 = X(:,1); xUn2 = X(:,2); xUn3 = X(:,3); xUn4 = X(:,4);

A. Please advise how to use function INTERPN.
I tried 'ppXI = interpn(t,t,t,t,X,xUn1,xUn2,xUn3,xUn4);', but it did
not work.

B. Please advise how to recall the co-efficients of interpolation and
use them to calculate uOpt.

[uOpt] = feval ('optCtrl', [t0 tf], x0, ppXI);
plot([t0 tf],uOpt);

function uOpt = optCtrl (t,x0,ppXI)
for n = 1:size(t,2)
uOpt(n,:) = -inv(R)*B'*ppval(ppXI,t);
end

t and x0 is same for whole process.

Please HELP! Thanks a lot!
.