资源简介
一份生成PWM波形的MATLAB编程文件,分享给大家一起学习
代码片段和文件信息
function [sysx0strts] = PWM_Generator(txuflag)
switch flag
case 0
[sysx0strts]=mdlInitializeSizes;
case 1
sys=[];
case 2
sys=[];
case 3
sys=mdlOutputs(txu);
case 4
sys=[];
case 9
sys=[];
otherwise
error([‘Unhandled flag = ‘num2str(flag)]);
end
%=============================================================================
% mdlInitializeSizes
function [sysx0strts]=mdlInitializeSizes
sizes = simsizes;
sizes.NumContStates = 0;
sizes.NumDiscStates = 0;
sizes.NumOutputs = 6;
sizes.NumInputs = 3;
sizes.DirFeedthrough = 1;
sizes.NumSampleTimes = 1; % at least one sample time is needed
sys = simsizes(sizes);
x0 = [];
str = [];
ts = [2e-6 0]; %每0.002秒算一次,500Hz开关频率
%=============================================================================
% mdlOutputs
function sys=mdlOutputs(txu)
global Ts T
global CMPR_HA CMPR_HB CMPR_HC
global Sa1 Sa2 Sb1 Sb2 Sc1 Sc2
Ts=0.0005;
T=t-fix(t/Ts)*Ts;
CMPR_HA=u(1);
CMPR_HB=u(2);
CMPR_HC=u(3);
if t==0
CMPR_H
- 上一篇:matlab边缘化处理代码
- 下一篇:异步电机矢量控制MATLAB 仿真
评论
共有 条评论