火柴杆图(`stem`)
火柴杆图(stem)
01_二维线图 5 张 MATLAB R2023b 100 mm 宽 @ 300 dpi
这个方法适合什么
离散序列用一根杆加一个点表示,不连线以免暗示中间有值。适合:谐波各次幅值、采样序列、离散控制指令、脉冲序列。
电气场景
1 电流离散采样序列

2 谐波幅值谱

3 电压暂降残余电压序列

4 光伏出力离散采样

5 电池SOC采样点

代码
脚本 p1_line_plots.m 中对应 stem 的一段,SEL 用于选择只跑某几个方法。
if any(SEL==6)
% ---- 6.1 电流离散采样序列 ----
t = 0:0.0005:0.02;
i1 = 320*sin(2*pi*50*t);
tr = linspace(0,0.02,800);
ir = 320*sin(2*pi*50*tr);
f = ml_fig(PP,100,80);
ax = axes('Parent',f,'Position',[0.175 0.190 0.770 0.755]);
h1 = stem(ax,t,i1,'Color',C(1,:),'LineWidth',0.7,'MarkerSize',3,'MarkerFaceColor',C(1,:)); hold(ax,'on');
h2 = plot(ax,tr,ir,'Color',[0.55 0.55 0.55],'LineWidth',0.8);
xlabel(ml_tx('时间 <i>t</i> / s'));
ylabel(ml_tx('采样电流 <i>i</i> / A'));
xlim(ax,[0 0.02]); ylim(ax,[-420 560]);
lg = legend(ax,[h1 h2],ml_tx({'2 kHz 采样','连续波形'}),'Location','northeast','Orientation','horizontal');
ml_style_legend(lg,PP);
save_png(f,FIGD,'电流离散采样序列');
% ---- 6.2 谐波幅值谱 ----
hh = 1:2:31;
I1 = 120./hh.^1.2;
I2 = 12./hh.^2.4;
f = ml_fig(PP,100,80);
ax = axes('Parent',f,'Position',[0.175 0.190 0.770 0.755]);
h1 = stem(ax,hh,I1,'Color',C(2,:),'LineWidth',0.9,'MarkerSize',4,'MarkerFaceColor',C(2,:)); hold(ax,'on');
h2 = stem(ax,hh,I2,'Color',C(1,:),'LineWidth',0.9,'MarkerSize',4,'MarkerFaceColor',C(1,:));
xlabel(ml_tx('谐波次数 <i>h</i>'));
ylabel(ml_tx('谐波幅值 <i>I_h</i> / A'));
xlim(ax,[0 32]); ylim(ax,[0 165]);
lg = legend(ax,[h1 h2],ml_tx({'滤波前','滤波后'}),'Location','northeast');
ml_style_legend(lg,PP);
save_png(f,FIGD,'谐波幅值谱');
% ---- 6.3 电压暂降残余电压序列 ----
ev = 1:12;
u1 = [0.82 0.35 0.68 0.15 0.55 0.90 0.42 0.25 0.72 0.48 0.30 0.88];
u2 = [0.88 0.52 0.75 0.28 0.65 0.94 0.58 0.40 0.80 0.60 0.45 0.92];
f = ml_fig(PP,100,80);
ax = axes('Parent',f,'Position',[0.175 0.190 0.770 0.755]);
h1 = stem(ax,ev,u1,'Color',C(1,:),'LineWidth',0.9,'MarkerSize',5,'MarkerFaceColor',C(1,:)); hold(ax,'on');
h2 = stem(ax,ev,u2,'Color',C(2,:),'LineWidth',0.9,'MarkerSize',5,'MarkerFaceColor',C(2,:));
yline(ax,0.9,'Color',[0.5 0.5 0.5],'LineStyle','--','LineWidth',0.7);
xlabel(ml_tx('事件序号 <i>k</i>'));
ylabel(ml_tx('残余电压 <i>u</i> / pu'));
xlim(ax,[0 13]); ylim(ax,[0 1.32]);
lg = legend(ax,[h1 h2],ml_tx({'母线 I','母线 II'}),'Location','northeast');
ml_style_legend(lg,PP);
save_png(f,FIGD,'电压暂降残余电压序列');
% ---- 6.4 光伏出力离散采样 ----
hr = 6:18;
P1 = 8.5*sin(pi*(hr-6)/12);
k = [0.95 0.82 0.58 0.36 0.52 0.78 0.92 0.86 0.62 0.46 0.63 0.82 0.94];
P2 = P1.*k;
f = ml_fig(PP,100,80);
ax = axes('Parent',f,'Position',[0.175 0.190 0.770 0.755]);
h1 = stem(ax,hr,P1,'Color',C(6,:),'LineWidth',1.0,'MarkerSize',5,'MarkerFaceColor',C(6,:)); hold(ax,'on');
h2 = stem(ax,hr,P2,'Color',C(1,:),'LineWidth',1.0,'MarkerSize',5,'MarkerFaceColor',C(1,:));
xlabel(ml_tx('时刻 <i>t</i> / h'));
ylabel(ml_tx('出力 <i>P</i> / MW'));
xlim(ax,[5 19]); ylim(ax,[0 11.5]);
lg = legend(ax,[h1 h2],ml_tx({'晴天','多云'}),'Location','northeast');
ml_style_legend(lg,PP);
save_png(f,FIGD,'光伏出力离散采样');
% ---- 6.5 电池 SOC 采样点 ----
k = 0:20;
s1 = 100 - 3.2*k;
s2 = 100 - 4.1*k;
f = ml_fig(PP,100,80);
ax = axes('Parent',f,'Position',[0.175 0.190 0.770 0.755]);
h1 = stem(ax,k,s1,'Color',C(1,:),'LineWidth',0.9,'MarkerSize',4,'MarkerFaceColor',C(1,:)); hold(ax,'on');
h2 = stem(ax,k,s2,'Color',C(2,:),'LineWidth',0.9,'MarkerSize',4,'MarkerFaceColor',C(2,:));
xlabel(ml_tx('采样点 <i>k</i>'));
ylabel(ml_tx('荷电状态 <i>SOC</i> / %'));
xlim(ax,[-1 21]); ylim(ax,[0 128]);
lg = legend(ax,[h1 h2],ml_tx({'0.5<i>C</i> 放电','1<i>C</i> 放电'}),'Location','northeast');
ml_style_legend(lg,PP);
save_png(f,FIGD,'电池SOC采样点');
end

浙公网安备 33010602011771号