clear all;clc;
[A,Name,allData]=xlsread(Nametable,'knowing someones dialect'); %read excel
r_size=size(Name);
if r_size(1)~=r_size(2) %判断是否为方阵
disp('NOT A SQUARE MATRIX');
return;
end
len=r_size(1);
r=1.35
w=floor(sqrt(len)); %使点的分布尽可能的随机避免重合点
h=floor(len/w);
for i=1:h
for j=1:w
pointx=98*rand(len,1)+(j-1)*19;
pointy=97*rand(len,1)+(i-1)*13;
end
end
pointx=floor(pointx);
pointy=floor(pointy);
theta=0:pi/25:2*pi;
[tempx,tempy]=pol2cart(theta',r);
point=[pointx,pointy]; %50*2
hold on; %保存axes内图像用的,如果你在新画图像之后不想覆盖原图像就要加上hold on这句话
for i=1:len
temp=[tempx,tempy]+[point(i,1)*ones(length(tempx),1),point(i,2)*ones(length(tempx),1)];
plot(temp(:,1),temp(:,2),'b');
fill(temp(:,1),temp(:,2),'y');
text(point(i,1)-0.5,point(i,2),num2str(i),'FontName','黑体',&#
【Matlab】将图的矩阵转化成无向图
最新推荐文章于 2020-07-20 20:26:45 发布