



下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、Matlab中根据邻接矩阵做图function tu_plot(rel,control)%由邻接矩阵画图%输入为邻接矩阵,必须为方阵;%第二个输入为控制量,0表示无向图,1表示有向图。默认值为0r_size=size(rel);if nargin<2 control=0;endif r_size(1)=r_size(2) disp('Wrong Input! The input must be a square matrix!'); return;endlen=r_size(1);rho=10;%限制图尺寸的大小r=2/1.05len;%点的半径theta=0:(2*pi
2、/len):2*pi*(1-1/len);pointx,pointy=pol2cart(theta',rho);theta=0:pi/36:2*pi;tempx,tempy=pol2cart(theta',r);point=pointx,pointy;hold onfor 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),'r'); text(point(i,1)-0.3,poin
3、t(i,2),num2str(i); %画点endfor i=1:len for j=1:len if rel(i,j) link_plot(point(i,:),point(j,:),r,control); %连接有关系的点 end endendset(gca,'XLim',-rho-r,rho+r,'YLim',-rho-r,rho+r);axis off%function link_plot(point1,point2,r,control)%连接两点temp=point2-point1;if (temp(1)&&(temp(2) retur
4、n; %不画子回路;endtheta=cart2pol(temp(1),temp(2);point1_x,point1_y=pol2cart(theta,r);point_1=point1_x,point1_y+point1;point2_x,point2_y=pol2cart(theta+(2*(theta<pi)-1)*pi,r);point_2=point2_x,point2_y+point2;if control arrow(point_1,point_2);else plot(point_1(1),point_2(1),point_1(2),point_2(2);end%fun
5、ction arrow(start,stop,l)%start,stop分别为起点和终点%l为箭头的线长度,默认为主线长的1/10t=0.1;ang=15/180*pi;temp=stop(1)-start(1)+j*(stop(2)-start(2);L=abs(temp);P=angle(temp);if nargin<3 l=t*L;endp1=P-ang;p2=P+ang;a=stop(1)-l*cos(p1) stop(2)-l*sin(p1);b=stop(1)-l*cos(p2) stop(2)-l*sin(p2);hold onplot(start(1) stop(1),start(2) stop(2);plot(a(1) stop(1),a(2) stop(2);plot(b(1) stop(1),b(2) stop(2);end效果图如下:邻接矩阵为 0 1 0 0 0 0 0 0 0 0 0 1
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 绿色能源技术研发合作合同
- 医疗器械代理注册合同书
- 正式借款合同
- 城市绿化项目实施与验收合同
- 节电小贴士(教学设计)-2023-2024学年四年级下册综合实践活动沪科黔科版
- 第21课《庄子二则-北冥有鱼》教学设计 2023-2024学年统编版语文八年级下册
- 社区团购仓储租赁协议
- 第5课计算机的资源管理 教学设计
- 律师事务所劳动仲裁合同8篇
- 无产权房屋买卖合同范本5篇
- 农业托管合同范例
- 食品中阿维菌素等55种农药最大残留限量
- 保洁部消杀培训
- 口服轮状疫苗知识课件
- 中国脑小血管病诊治指南2023版
- 中国聚乙烯催化剂行业发展状况及需求规模预测研究报告(2024-2030版)
- 新能源汽车驱动电机及控制系统检修课件 学习情境4:电的转换
- 车辆实际使用权协议书范文模板
- 新版加油站全员安全生产责任制
- 脑出血课件完整版本
- 凉山州小学数学教师业务素质考试试题(真题+训练)
评论
0/150
提交评论