你可以使用3D矩阵来做到这一点:
[A,B] = meshgrid(0:10,1:10);
U(1,1,:) = [1,1,0];
V(1,1,:) = [1,0,1];
s = A.U + B.V;
% s is now a NxMx3 matrix, where N = length(A) and M = length(B)
% We can plot how s varies with a and b as follows
surf(A,B,s(:,:,1)); % first component
surf(A,B,s(:,:,2)); % second component
surf(A,B,s(:,:,3)); % third component
</code>