图像着色图(`imagesc`)
图像着色图(imagesc)
03_统计与矩阵 5 张 MATLAB R2023b 100 mm 宽 @ 300 dpi
这个方法适合什么
按数值直接着色,比 pcolor 快且不丢边缘一行一列。适合:节点×时刻的电压热力图、谐波次数×测点的含有率矩阵。
电气场景
1 月时负荷矩阵

2 节点时刻电压偏差矩阵

3 各馈线日负荷矩阵

4 谐波阻抗矩阵

5 光伏出力矩阵

代码
脚本 p3_stats_matrix.m 中对应 imagesc 的一段,SEL 用于选择只跑某几个方法。
if any(SEL==5)
rng(505);
hr = 0:23;
% ---- 5.1 月时负荷矩阵 ----
mn = ml_tx(arrayfun(@(k) sprintf('%d 月',k),1:12,'UniformOutput',false));
Cm = 6.5 + 0.9*randn(12,24) + 2.2*repmat((1+0.09*(1:12)'),1,24).* ...
(0.55 + 0.45*exp(-((hr-10).^2)/20) + 0.5*exp(-((hr-19).^2)/12));
f = ml_fig(PP,100,85);
ax = axes('Parent',f,'Position',[0.165 0.175 0.680 0.740]);
imagesc(ax,hr,1:12,Cm);
set(ax,'YDir','normal','YTick',1:12,'YTickLabel',mn,'XTick',0:2:22);
xlabel(ml_tx('时刻 / h')); ylabel(ml_tx('月份'));
colormap(ax,parula);
cb = colorbar(ax); cb.FontName = PP.FontEN; cb.FontSize = PP.FS;
cb.Label.String = ml_tx('负荷 <i>P</i> / MW'); cb.Label.FontName = PP.FontEN;
save_png(f,FIGD,'月时负荷矩阵');
% ---- 5.2 节点时刻电压偏差 ----
dv = ml_tx({'N1','N2','N3','N4','N5','N6','N7','N8'});
Cm = 0.75*randn(8,24);
Cm(3,:) = Cm(3,:) - 1.5; Cm(6,:) = Cm(6,:) + 1.1;
cmap = div_cmap(0.10,0.42,0.72, 0.72,0.10,0.16);
f = ml_fig(PP,100,85);
ax = axes('Parent',f,'Position',[0.165 0.175 0.665 0.740]);
imagesc(ax,hr,1:8,Cm);
set(ax,'YDir','normal','YTick',1:8,'YTickLabel',dv,'XTick',0:2:22);
xlabel(ml_tx('时刻 / h')); ylabel(ml_tx('节点编号'));
colormap(ax,cmap); clim(ax,[-3 3]);
cb = colorbar(ax); cb.FontName = PP.FontEN; cb.FontSize = PP.FS;
cb.Label.String = ml_tx('电压偏差 Δ<i>U</i> / %');
cb.Label.FontName = PP.FontEN;
save_png(f,FIGD,'节点时刻电压偏差矩阵');
% ---- 5.3 各馈线日负荷矩阵 ----
fd = ml_tx({'F1','F2','F3','F4','F5','F6'});
Cm = 120 + 30*randn(6,24) + 190*repmat([1.0 0.9 0.75 0.8 0.95 0.6]',1,24).* ...
(0.45 + 0.55*exp(-((hr-9).^2)/22) + 0.62*exp(-((hr-19).^2)/10));
f = ml_fig(PP,100,85);
ax = axes('Parent',f,'Position',[0.135 0.175 0.715 0.740]);
imagesc(ax,hr,1:6,Cm);
set(ax,'YDir','normal','YTick',1:6,'YTickLabel',fd,'XTick',0:2:22);
xlabel(ml_tx('时刻 / h')); ylabel(ml_tx('馈线编号'));
colormap(ax,turbo);
cb = colorbar(ax); cb.FontName = PP.FontEN; cb.FontSize = PP.FS;
cb.Label.String = ml_tx('电流 <i>I</i> / A'); cb.Label.FontName = PP.FontEN;
save_png(f,FIGD,'各馈线日负荷矩阵');
% ---- 5.4 谐波阻抗矩阵 ----
ho = string(3:2:25);
nd = ml_tx({'N1','N2','N3','N4','N5','N6'});
Z = zeros(6,12);
for k = 1:12
Z(:,k) = (0.08 + 0.055*k)*(1 + 0.12*randn(6,1));
end
f = ml_fig(PP,100,85);
ax = axes('Parent',f,'Position',[0.165 0.175 0.665 0.740]);
imagesc(ax,1:12,1:6,log10(Z));
set(ax,'YDir','normal','YTick',1:6,'YTickLabel',nd, ...
'XTick',1:12,'XTickLabel',ho);
xlabel(ml_tx('谐波次数')); ylabel(ml_tx('节点编号'));
colormap(ax,parula);
cb = colorbar(ax); cb.FontName = PP.FontEN; cb.FontSize = PP.FS;
cb.Label.String = ml_tx('lg(<i>Z</i>_{h} / Ω)'); cb.Label.FontName = PP.FontEN;
save_png(f,FIGD,'谐波阻抗矩阵');
% ---- 5.5 光伏出力矩阵 ----
mn = ml_tx(arrayfun(@(k) sprintf('%d 月',k),1:12,'UniformOutput',false));
Cm = zeros(12,24);
for m = 1:12
amp = 0.62 + 0.30*sin((m-3)/12*2*pi);
Cm(m,:) = amp*exp(-((hr-12.5).^2)/12) + 0.015*randn(1,24);
end
Cm = max(Cm,0);
f = ml_fig(PP,100,85);
ax = axes('Parent',f,'Position',[0.165 0.175 0.680 0.740]);
imagesc(ax,hr,1:12,Cm);
set(ax,'YDir','normal','YTick',1:12,'YTickLabel',mn,'XTick',0:2:22);
xlabel(ml_tx('时刻 / h')); ylabel(ml_tx('月份'));
colormap(ax,flipud(hot));
cb = colorbar(ax); cb.FontName = PP.FontEN; cb.FontSize = PP.FS;
cb.Label.String = ml_tx('出力 <i>P</i>_{pv} / p.u.'); cb.Label.FontName = PP.FontEN;
save_png(f,FIGD,'光伏出力矩阵');
end

浙公网安备 33010602011771号