我有一项作业,基本上需要创建一个函数,给定两个基础(我将其表示为向量矩阵),它应该返回基础矩阵从一个基础到另一个基础的变化。
到目前为止,这是我根据接下来要解释的算法提出的函数:
function C = cob(A, B)
% Returns C, which is the change of basis matrix from A to B,
% that is, given basis A and B, we represent B in terms of A.
% Assumes that A and B are square matrices
n = size(A, 1);
% Creates a square matrix full of zeros
% of the same size as the number of rows of A.
C = zeros(n);
for i=1:n
C(i, :) = (A\B(:, i))';
end …Run Code Online (Sandbox Code Playgroud)