Matlab 绘制盖尔圆
程序员文章站
2022-03-10 16:05:43
...
Matlab 绘制盖尔圆
根据输入矩阵,绘制盖尔圆
clear;
clc;
% 利用矩阵(方阵)绘制盖尔圆
% 圆盘中心是对角线元素
% 圆盘半径是每行元素总和
% 缺点:只能计算实数,虽然写了复数,但还需要调试
% 待求矩阵
A = [0.90, 0.01, 0.12;
0.01, 0.80, 0.13;
0.01, 0.02, 0.40;];
n = size(A);
nRow = n(1);
nCol = n(2);
% 提取圆心
i = 1;
while (i<=nRow)
CircleCenter(i,:) = A(i,i);
i = i + 1;
end
RowSum = sum(A,2);
R = RowSum - CircleCenter;
RealX = real(CircleCenter);
ImagY = imag(CircleCenter);
% 根据圆心和半径绘制圆
j = 1;
while (j<=nRow)
x = RealX(j,:);
y = ImagY(j,:);
r = R(j,:);
scatter(x,y);
hold on
rectangle('Position',[x-r,y-r,2*r,2*r],'Curvature',[1,1]),axis equal
j = j + 1;
end
grid on
Ref: 绘制虚数和复数数据图
Ref: matlab指定圆心坐标和半径画圆