
function [] = Coordinate( )
x=-10:1:10; y=-10:1:10;z=-10:1:10;
%绘制网格
plot(x,meshgrid(x,y),'k:')
hold on
plot(meshgrid(x,y),y,'k:')
hold on
plot(meshgrid(x,z),z,'k:')
axis off; % 隐藏默认坐标轴和刻度
%正方形坐标系
axis square;
%启动图形保持功能
hold on;
% 画两条相互垂直的线
plot([0 0],[min(y) max(y)],'k',[min(x) max(x)],[0 0],'k');
% x 轴箭头,fill填充函数
ax=[max(x),max(x)-0.3,max(x)-0.3;0,0.2,-0.2];
fill(ax(1,:),ax(2,:),'k');
% y 轴箭头,fill填充函数
ay=[0,0.15,-0.15;max(y),max(y)-0.4,max(y)-0.4];
fill(ay(1,:),ay(2,:),'k');
hold on;
for i=1:length(x)-1
if x(i)~=0
% 画 x 轴刻度
plot([x(i),x(i)],[0,0.1],'k');hold on;
% 在图形中指定的位置(x,y)上显示字符串string
a=text(x(i),-0.4,num2str(x(i)));
set(a,'HorizontalAlignment','center')
end
if y(i)~=0
% 画 y 轴刻度
plot([0,0.1],[y(i),y(i)],'k');hold on;
b=text(-0.4,y(i),num2str(y(i)));
set(b,'HorizontalAlignment','center')
end
end
c=text(-0.4,-0.4,num2str(0));
set(c,'HorizontalAlignment','center');
set(0,'defaultfigurecolor','w');
end
%COORDINATE Summary of this function goes here
% Detailed explanation goes here
x=-10:1:10; y=-10:1:10;z=-10:1:10;
%绘制网格
plot(x,meshgrid(x,y),'k:')
hold on
plot(meshgrid(x,y),y,'k:')
hold on
plot(meshgrid(x,z),z,'k:')
axis off; % 隐藏默认坐标轴和刻度
%正方形坐标系
axis square;
%启动图形保持功能
hold on;
% 画两条相互垂直的线
plot([0 0],[min(y) max(y)],'k',[min(x) max(x)],[0 0],'k');
% x 轴箭头,fill填充函数
ax=[max(x),max(x)-0.3,max(x)-0.3;0,0.2,-0.2];
fill(ax(1,:),ax(2,:),'k');
% y 轴箭头,fill填充函数
ay=[0,0.15,-0.15;max(y),max(y)-0.4,max(y)-0.4];
fill(ay(1,:),ay(2,:),'k');
hold on;
for i=1:length(x)-1
if x(i)~=0
% 画 x 轴刻度
plot([x(i),x(i)],[0,0.1],'k');hold on;
% 在图形中指定的位置(x,y)上显示字符串string
a=text(x(i),-0.4,num2str(x(i)));
set(a,'HorizontalAlignment','center')
end
if y(i)~=0
% 画 y 轴刻度
plot([0,0.1],[y(i),y(i)],'k');hold on;
b=text(-0.4,y(i),num2str(y(i)));
set(b,'HorizontalAlignment','center')
end
end
c=text(-0.4,-0.4,num2str(0));
set(c,'HorizontalAlignment','center');
set(0,'defaultfigurecolor','w');
end
%COORDINATE Summary of this function goes here
% Detailed explanation goes here
只有本站会员才能查看附件,请 登录