Interpolate matrix functrion. Concatate n-dim matrices

Hi, all. I have two 3D matrixes (arrays of matrix function values and derivatives). And I need to concatate it to pass function spapi.
function test()
t = linspace(0, 1, 10);
for i = 1:length(t)
a(:,:,i) = A(t(i));
da(:,:,i) = dA(t(i));
end
% I need to obtain the following array:
% [a(:, :, 1) a(:, :, 2) ... a(:, :, 10) da(:, :, 1) da(:, :, 2) ... da(:, :, 10)]
y = [a da] % doesn't work
y = [a; da] % doesn't work
y = [a, da] % doesn't work
% after i'd like to interpolate
sp = spapi(4, [t t], y);
disp(sp.coefs);
disp(spval(sp, 0.21) - A(0.21)); % doesn't work
end
function a = A(t)
a = [exp(t), exp(2*t); exp(3*t), exp(4*t)];
end
function a = dA(t)
a = [exp(t), 2*exp(2*t); 3*exp(3*t), 4*exp(4*t)];
end
Hence 2 questions:
  1. How to concatate two 3D matrixes by third index?
  2. How to obtain values of interpolated function? spval(sp, 0.21) doesn't work for matrixes.

More Answers (0)

Categories

Find more on Instrument Control Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!