施密特正交化法求正交向量组
代码如下:
%% 向量正交,两个向量内积等于,则称这两个向量正交,记作a垂直b
a1 = [1,2,3,4];
a2 = [2,3,4,5];
a3 = [3,4,5,6];
%% 求正交向量组,施密特正交化法
%% 先固定一个值y=a1
y = zeros(4,3);
y1 = a1;
y2 = a2 - dot(a2,y1)/dot(y1,y1)*y1;
y3 = a3 - dot(a3,y1)/dot(y1,y1)*y1 - dot(a3,y2)/dot(y2,y2)*y2;
% 然后单位化
y1 = y1/norm(y1);
y2 = y2/norm(y2);
y3 = y3/norm(y3);
y(:,1) = y1;
y(:,2) = y2;
y(:,3) = y3;
disp(y)
参考书上图片: