仅作为记录
matlab绘制折线图
直接上代码:
x=[1e-3,1e-4,1e-5];
a=[12,26,40];
plot(x,a,'*');
运行结果是不带线的
若想带线,将最后一行代码的*
改成-*
即可:
plot(x,a,'-*');
Matlab作折现图:等间距坐标距离表示不等间距数据值
直接上代码:
clear;clc;close all; %画折线图
x=[1e-3,1e-4,1e-5]; int=1:length(x);
a=[12,26,40];
b=[4,5,6];
plot(int,a,'-*',int,b,'-*');
xlabel('计算精度');
ylabel('迭代次数');
legend('GS','NR');
axis([0,length(x)+1,0,50]); %留出前后的空隙
set(gca,'XTick',int);
set(gca,'XTickLabel',{'1e-3','1e-4','1e-5'});
之前未留空隙的图是这样的:
其他感谢:
传送门-set XTick和XTickLabel