% Power Quality Harmonic Interactive Demo
% This interactive demo generates power quality harmonic waveform up to
% 15th orders based on numerical modeling approach.
% This demo also visualize the harmonic in frequency domain and computes
% the its Total Harmonic Distortion.
% It allows user to set the magnitude and phase for each harmonic order.
% The harmonic waveform can then save as .mat file format.
function PQHarmonicDemoMain
figure('NumberTitle','off','Toolbar','none',...
'Name','Power Quality Harmonic Interactive Demo');
hTD = zeros(1,320);
h = [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
hlast = [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
ph = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
phlast = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
subplot(3,1,1);
subplot(3,1,2);
uicontrol('Style', 'text', 'String', '幅值 (pu)',...
'Position', [80 90 80 20],'horizontalAlignment', 'left');
uicontrol('Style', 'text', 'String', '相位 (deg)',...
'Position', [80 60 80 20],'horizontalAlignment', 'left');
uicontrol('Style', 'text', 'String', '谐波阶数',...
'Position', [80 30 80 20],'horizontalAlignment', 'left');
hMagTxt = uicontrol('Style','edit','string','1','Enable','inactive',...
'Position', [170 90 40 20],'BackgroundColor','w',...
'horizontalAlignment','left');
hMagSldr = uicontrol('Style','slider','Min',0,'Max',1 ,'Value',1,...
'SliderStep', [0.01, 0.1],...
'Position',[205 90 15 20],'Callback',@harmonic);
hPhTxt = uicontrol('Style','edit','string','0','Enable','inactive',...
'Position', [170 60 40 20],'BackgroundColor','w',...
'horizontalAlignment','left');
hPhSldr = uicontrol('Style','slider','Min',0,'Max',180 ,'Value',0,...
'SliderStep', [1/18, 0.1],...
'Position',[205 60 15 20],'Callback',@harmonic);
hOrder=uicontrol('Style', 'popup', 'String',1:16,...
'Position', [170 30 50 20],'Callback',@OrderSelect,...
'horizontalAlignment', 'left');
uicontrol('Style', 'text', 'String', '系统频率 (Hz)',...
'Position', [250 90 100 20],'horizontalAlignment', 'left');
uicontrol('Style', 'text', 'String', '采样频率 (Hz)',...
'Position', [250 60 100 20],'horizontalAlignment', 'left');
hFreqSelect=uicontrol('Style', 'popup', 'String',{'50','60'},'Value',1,...
'Position', [350 90 50 20],'Callback',@harmonic,...
'horizontalAlignment', 'left');
hFsTxt = uicontrol('Style','edit','string','1600','Enable','inactive',...
'Position', [350 60 50 20],'BackgroundColor','w',...
'horizontalAlignment','left');
hPreset=uicontrol('Style', 'popup', 'String',...
{'纯正弦波','1ph整流器谐波'},'Value',1,...
'Position', [250 20 150 30],'Callback',@Preset,...
'horizontalAlignment', 'left');
uicontrol('Style', 'pushbutton', 'String', '导出数据',...
'Position', [430 30 80 80],'Callback',@Export);
harmonic;
function Export(~,~)
uisave('hTD','harmonic');
end
function Preset(~,~)
switch get(hPreset,'Value')
case 1
h = [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
hlast = [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
ph = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
phlast = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
case 2
h = [1,0,0.8,0,0.6,0,0.4,0,0.2,0,0.1,0,0,0,0];
hlast = [1,0,0.8,0,0.6,0,0.4,0,0.2,0,0.1,0,0,0,0];
ph = [0,0,180,0,0,0,180,0,0,0,180,0,0,0,0];
phlast = [0,0,180,0,0,0,180,0,0,0,180,0,0,0,0];
end
OrderSelect;
harmonic;
end
function OrderSelect(~,~)
switch get(hOrder,'Value')
case 1
set(hMagSldr,'Value',hlast(1));
set(hMagTxt,'String',get(hMagSldr,'Value'));
set(hPhSldr,'Value',phlast(1));
set(hPhTxt,'String',get(hPhSldr,'Value'));
case 2
set(hMagSldr,'Value',hlast(2));
set(hMagTxt,'String',get(hMagSldr,'Value'));
set(hPhSldr,'Value',phlast(2));
set(hPhTxt,'String',get(hPhSldr,'Value'));
case 3
set(hMagSldr,'Value',hlast(3));
set(hMagTxt,'String',get(hMagSldr,'Value'));
set(hPhSldr,'Value',phlast(3));
set(hPhTxt,'String',get(hPhSldr,'Value'));
case 4
set(hMagSldr,'Value',hlast(4));
set(hMagTxt,'String',get(hMagSldr,'Value'));
set(hPhSldr,'Value',phlast(4));
set(hPhTxt,'String',get(hPhSldr,'Value'));
case 5
set(hMagSldr,'Value',hlast(5));
set(hMagTxt,'String',get(hMagSldr,'Value'));
set(hPhSldr,'Value',phlast(5));
set(hPhTxt,'String',get(hPhSldr,'Value'));
case 6
set(hMagSldr,'Value',hlast(6));
set(hMagTxt,'String',get(hMagSldr,'Value'));
set(hPhSldr,'Value',phlast(6));
set(hPhTxt,'String',get(hPhSldr,'Value'));
case 7
set(hMagSldr,'Value',hlast(7));
set(hMagTxt,'String',get(hMagSldr,'Value'));
set(hPhSldr,'Value',phlast(7));
set(hPhTxt,'String',get(hPhSldr,'Value'));
case 8
set(hMagSldr,'Value',hlast(8));
set(hMagTxt,'String',get(hMagSldr,'Value'));
set(hPhSldr,'Value',phlast(8));
set(hPhTxt,'String',get(hPhSldr,'Value'));
case 9
set(hMagSldr,'Value',hlast(9));
set(hMagTxt,'String',get(hMagSldr,'Value'));
set(hPhSldr,'Value',phlast(9));
set(hPhTxt,'String',get(hPhSldr,'Value'));
case 10
set(hMagSldr,'Value',hlast(10));
set(hMagTxt,'String',get(hMagSldr,'Value'));
set(hPhSldr,'Value',phlast(10));
set(hPhTxt,'String',get(hPhSldr,'Value'));
case 11
set(hMagSldr,'Value',hlast(11));
set(hMagTxt,'String',get(hMagSldr,'Value'));
set(hPhSldr,'Value',phlast(11));
set(hPhTxt,'String',get(hPhSldr,'Value'));
case 12
set(hMagSldr,'Value',hlast(12));
set(hMagTxt,'String',get(hMagSldr,'Value'));
set(hPhSldr,'Value',phlast(12));
set(hPhTxt,'String',get(hPhSldr,'Value'));
case 13
set(hMagSldr,'Value',hlast(13));
set(hMagTxt,'String',get(hMagSldr,'Value'));
set(hPhSldr,'Value',phlast(13));
set(hPhTxt,'String',get(hPhSldr,'Value'));
case 14
set(hMagSldr,'Value',hlast(14));
set(hMagTxt,'String',get(hMagSldr,'Value'));
set(hPhSldr,'Value',phlast(14));
set(hPhTxt,'String',get(hPhSldr,'Value'));
case 15
set(hMagSldr,'Value',hlast(15));
set(hMagTxt,'String',get(hMagSldr,'Value'));
set(hPhSldr,'Value',phlast(15));
set(hPhTxt,'String',get(hPhSldr,'Value'));
end
end
function harmonic(~,~)
if get(hFreqSelect,'Value')==1
f = 50;
fs = 1600;
t = 1/fs:1/fs:0.2;
set(hFsTxt,'String','1600');
else
f =


海神之光
- 粉丝: 5w+
- 资源: 7136
最新资源
- GitHub新手使用教程(Windows Git从安装到使用).docx
- Matlab Simulink下的双馈风机控制策略比较研究:超速减载变桨调频与下垂控制及虚拟惯性控制的应用分析于三机九节点系统中,Matlab Simulink下的双馈风机全套控制策略解析:超速减载变
- 基于深度强化学习的无人机自主避障与目标追踪:MP-DQN算法Python实现(论文复现含可运行代码及解释共18页)
- Linux下Nginx+Tomcat负载均衡和动静分离配置要点.docx
- Deepseek免费无卡顿五大访问全攻略:多平台实现AI快速响应
- 电脑装机必备软件清单/windows装机必备软件库
- 图书管理系统BOOKMS winform+sqlite
- C++实现单目相机与投影仪标定算法,yml格式输出结果,重投影误差小于0.1像素,单目相机与投影仪标定算法研究:C++实现,yml格式输出,重投影误差低于0.1像素,单目相机+投影仪标定算法,C++语
- 非线性七自由度模型搭建与CarSim联合仿真验证:车速50km/h路面附着力0.8时的模型精度与误差分析,非线性七自由度模型搭建与CarSim联合仿真验证:车速50km/h路面附着力0.8下的模型精度
- 永磁同步电机转速滑模控制与电流矢量双闭环控制Matlab仿真模型:原理说明与文献参考,永磁同步电机转速滑模控制与电流矢量双闭环控制Matlab仿真模型:原理说明与文献参考,永磁同步电机转速滑模控制Ma
- 软件面试题宝典.docx
- 基于MATLAB的菲涅尔公式计算:P波、S波振幅透射与反射系数及其比值分析,自然光透射反射比的算法实现 ,基于MATLAB的菲涅尔公式计算:P波、S波振幅透射反射系数及比值分析,以及自然光透反特性研究
- 基于Next.js和Deepseek API开发的智能闪卡学习工具
- java调用科大讯飞在线语音合成API
- STM32C8T6库函数实现SG90和SH04扫描测距完整代码工程
- C# LitJson 案例
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈


