MATLAB产生SPWM比较占空比


根据实际需要 利用matlab 产生C语言数组

clc
dots = 120;     %%半周期点数
row_max = 4;    %%每行显示多少个数字
lines = 30;     %dots/dow_max

fid = fopen('C:\mout.txt','wt+');
                %自行决定文件名
x=(pi)/dots:(pi)/dots:pi;    
                %%正弦波分等份
Uu=sin(x);
Du=Uu;
%%Du=Du/2;
tu1 = Du * 65535;
spwmOut = fix(tu1);

mout = reshape(spwmOut,4,lines);
mout = mout';
for row = 1:lines
    for col = 1: row_max
        fprintf(fid,'0x%04X,',mout(row,col));
    end
    fprintf(fid,'\n');
end
getzeros = zeros(30,4);
for row = 1:lines
    for col = 1: row_max
        fprintf(fid,'0x%04X,',getzeros(row,col));
    end
    fprintf(fid,'\n');
end
fclose(fid);



matlab实现SPWM波形的产生

实际设计中需要产生SPWM波形

你可能感兴趣的:(数组,matlab,fprintf)