MATLAB: How to creat SPWM waveform

MATLAB and Simulink Student Suitesimulinkspwmwaveform

Hello, I want to know how to creat the SPWM waveform in matlab to put in amplifier software, arbexpress. Before that I used the signal builder block in simulink and I changed the this data in .xls file. I can change xls file in software which reconize the amplifier. Now i want to creat the SPWM waveform with different modulation ratio. Please give me the way how i can do that. Thanks.

Best Answer

clear all;
clc;
Fs = 10000000; %frecuencia de sampling (en Hz)(nota para el salame tiene q ser 10 veses mayor a la reiangular por q si no la recorta)
F_triangle =15000; %frecuencia de l; triangular
F_seno = 50 ; %frecuencia de la onda senoidal
Cant_periodos=10; %cantidad de perios de la senal seno
A_tirangle=.9 ; % amplitud de la triangular
A_seno=1 ; % amplitud de la Senoidal
T = Cant_periodos*(1/F_seno); %calculo el fianl de la cadena
t = 0:1/Fs:T-1/Fs; %vector de tiempo
Triangle= sawtooth(2*pi*F_triangle*t,1/2); %onda triangular
Seno=sin(2*pi*t*F_seno); %onda senoidal
Triangle=Triangle*A_tirangle; %modifico la aplitud de la triangular
Seno=Seno*A_seno ; %modifico la aplitud del seno
Compare = Triangle > Seno; %comparo las senales para generar el spwm
subplot(3,1,1);
plot(t,Triangle,"red",t,Seno,"blue")
title('Seno y Triangular')
grid on
subplot(3,1,2);
plot(t,Compare)
title('SPWM TR1!!!')
grid on
Related Question