How can i generate regular sampling PWM output using Matlab (Model)?

조회 수: 4 (최근 30일)
ali ABBAS
ali ABBAS 2014년 1월 2일
답변: Sabin 2025년 8월 12일
How can i generate regular sampling PWM output using Matlab (Model)?

답변 (1개)

Sabin
Sabin 2025년 8월 12일
A simple example in MATLAB that is generating a pulse for given duty cycle and frequency:
% Parameters
Fs = 10000; % Sampling frequency (Hz)
T = 1; % Duration (seconds)
f_pwm = 50; % PWM frequency (Hz)
duty_cycle = 30; % Duty cycle (%)
% Time vector
t = 0:1/Fs:T;
% Generate PWM signal
pwm_signal = square(2*pi*f_pwm*t, duty_cycle); % square()'s second argument is duty cycle
% Convert from [-1,1] to [0,1]
pwm_signal = (pwm_signal + 1)/2;
% Plot
figure;
plot(t, pwm_signal);
xlabel('Time (s)');
ylabel('Amplitude');
title(['PWM Signal: ', num2str(f_pwm), ' Hz, ', num2str(duty_cycle), '% Duty Cycle']);
axis([0 0.1 -0.2 1.2]); % Zoom on first 0.1 seconds
Simulink also contains a PWM block:

커뮤니티

더 많은 답변 보기:  Power Electronics Community

카테고리

Help CenterFile Exchange에서 Pulse and Transition Metrics에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by