函数曲线图(`fplot`)
函数曲线图(fplot)
01_二维线图 5 张 MATLAB R2023b 100 mm 宽 @ 300 dpi
这个方法适合什么
给函数句柄即可,自动按曲率加密采样,不必自己定 x 向量。适合:传递函数、非线性励磁特性、逆变器外特性、保护动作特性曲线。
电气场景
1 二阶系统阶跃响应

2 光伏组件IV特性

3 铁磁材料磁化曲线

4 逆变器死区非线性

5 继电器反时限特性

代码
脚本 p1_line_plots.m 中对应 fplot 的一段,SEL 用于选择只跑某几个方法。
if any(SEL==10)
% ---- 10.1 二阶系统阶跃响应 ----
wn = 2*pi*20;
rsp = @(t,z) 1 - exp(-z*wn*t)/sqrt(1-z^2).*sin(wn*sqrt(1-z^2)*t + acos(z));
f = ml_fig(PP,100,80);
ax = axes('Parent',f,'Position',[0.175 0.190 0.770 0.755]);
h1 = fplot(ax,@(t) rsp(t,0.20),[0 0.15],'Color',C(1,:),'LineWidth',1.1); hold(ax,'on');
h2 = fplot(ax,@(t) rsp(t,0.50),[0 0.15],'Color',C(2,:),'LineWidth',1.1);
h3 = fplot(ax,@(t) rsp(t,0.90),[0 0.15],'Color',C(3,:),'LineWidth',1.1);
xlabel(ml_tx('时间 <i>t</i> / s'));
ylabel(ml_tx('转速标幺值 <i>n</i>'));
xlim(ax,[0 0.15]); ylim(ax,[0 1.95]);
lg = legend(ax,[h1 h2 h3],ml_tx({'\epsilon = 0.2','\epsilon = 0.5','\epsilon = 0.9'}), ...
'Location','northeast');
ml_style_legend(lg,PP);
save_png(f,FIGD,'二阶系统阶跃响应');
% ---- 10.2 光伏组件 I-V 特性 ----
f = ml_fig(PP,100,80);
ax = axes('Parent',f,'Position',[0.175 0.190 0.770 0.755]);
iv = @(v,G) max(0, 10.4*(G/1000).*(1-exp((v-(44.5-2.2*log(1000/G)))/3.4)));
h1 = fplot(ax,@(v) iv(v,1000),[0 45],'Color',C(6,:),'LineWidth',1.2); hold(ax,'on');
h2 = fplot(ax,@(v) iv(v,700),[0 45],'Color',C(1,:),'LineWidth',1.2);
h3 = fplot(ax,@(v) iv(v,400),[0 45],'Color',C(3,:),'LineWidth',1.2);
xlabel(ml_tx('端电压 <i>U</i> / V'));
ylabel(ml_tx('电流 <i>I</i> / A'));
xlim(ax,[0 45]); ylim(ax,[0 17]);
lg = legend(ax,[h1 h2 h3],ml_tx({'1000 W/m^2','700 W/m^2','400 W/m^2'}), ...
'Location','northeast');
ml_style_legend(lg,PP);
save_png(f,FIGD,'光伏组件IV特性');
% ---- 10.3 铁磁材料磁化曲线 ----
f = ml_fig(PP,100,80);
ax = axes('Parent',f,'Position',[0.175 0.190 0.770 0.755]);
h1 = fplot(ax,@(h) 1.78*tanh(h/190),[0 900],'Color',C(1,:),'LineWidth',1.2); hold(ax,'on');
h2 = fplot(ax,@(h) 1.35*tanh(h/95), [0 900],'Color',C(2,:),'LineWidth',1.2);
xlabel(ml_tx('磁场强度 <i>H</i> / (A/m)'));
ylabel(ml_tx('磁感应强度 <i>B</i> / T'));
xlim(ax,[0 900]); ylim(ax,[0 2.55]);
lg = legend(ax,[h1 h2],ml_tx({'硅钢片','铁氧体'}),'Location','southeast');
ml_style_legend(lg,PP);
save_png(f,FIGD,'铁磁材料磁化曲线');
% ---- 10.4 逆变器死区非线性 ----
f = ml_fig(PP,100,80);
ax = axes('Parent',f,'Position',[0.175 0.190 0.770 0.755]);
dz = @(x,d) (x-d).*(x>d) + (x+d).*(x<-d);
h1 = fplot(ax,@(x) dz(x,0.02),[-0.4 0.4],'Color',C(1,:),'LineWidth',1.2); hold(ax,'on');
h2 = fplot(ax,@(x) dz(x,0.06),[-0.4 0.4],'Color',C(2,:),'LineWidth',1.2);
h3 = fplot(ax,@(x) dz(x,0.10),[-0.4 0.4],'Color',C(4,:),'LineWidth',1.2);
plot(ax,[-0.4 0.4],[-0.4 0.4],'Color',[0.6 0.6 0.6],'LineWidth',0.6,'LineStyle',':');
xlabel(ml_tx('指令电压 <i>u</i>^* / pu'));
ylabel(ml_tx('输出电压 <i>u</i> / pu'));
xlim(ax,[-0.4 0.4]); ylim(ax,[-0.42 0.42]);
lg = legend(ax,[h1 h2 h3],ml_tx({'死区 0.02 pu','死区 0.06 pu','死区 0.10 pu'}), ...
'Location','northwest');
ml_style_legend(lg,PP);
save_png(f,FIGD,'逆变器死区非线性');
% ---- 10.5 继电器反时限特性 ----
f = ml_fig(PP,100,80);
ax = axes('Parent',f,'Position',[0.175 0.190 0.770 0.755]);
h1 = fplot(ax,@(x) 0.14./(x.^0.02-1),[1.1 8],'Color',C(1,:),'LineWidth',1.2); hold(ax,'on');
h2 = fplot(ax,@(x) 13.5./(x-1), [1.1 8],'Color',C(2,:),'LineWidth',1.2);
h3 = fplot(ax,@(x) 80./(x.^2-1), [1.1 8],'Color',C(3,:),'LineWidth',1.2);
set(ax,'YScale','log');
xlabel(ml_tx('电流倍数 <i>I</i>/<i>I</i>_{set}'));
ylabel(ml_tx('动作时间 <i>t</i> / s'));
xlim(ax,[1.1 8]); ylim(ax,[0.4 600]);
lg = legend(ax,[h1 h2 h3],ml_tx({'标准反时限','非常反时限','极端反时限'}), ...
'Location','northeast');
ml_style_legend(lg,PP);
save_png(f,FIGD,'继电器反时限特性');
end
fprintf('\n[完成] 本次运行的函数编号:%s\n', mat2str(SEL));
%% ---------------------- 本地函数 ----------------------
function p = save_png(f, FIGD, nm)
%SAVE_PNG 导出 300dpi PNG + 边距自检 + 关图
p = fullfile(FIGD, ['01_二维线图_' nm '261107.png']);
print(f, p, '-dpng', '-r300');
ml_chkpng(p, 8);
close(f);
end

浙公网安备 33010602011771号