How to vary pulse frequency smoothly

4 ビュー (過去 30 日間)
優大
優大 2024 年 12 月 5 日
コメント済み: 優大 2024 年 12 月 7 日
I have created a 1000 Hz pulse wave in Simulink using the Repeating Sequence Stair block. How can I make this pulse wave vary sinusoidally between 500Hz and 1500Hz?

回答 (1 件)

Shubham
Shubham 2024 年 12 月 5 日
編集済み: Shubham 2024 年 12 月 5 日
HI @優大,
As per my understanding, you are trying to create a pulse wave with a frequency that varies sinusoidally between 500Hz and 1500Hz. You're currently using a Repeating Sequence Stair block for creating a 1000 Hz pulse wave.
Here is how you can achieve your goal using MATLAB Function block:
  • Use a MATLAB Function block: This block will allow you to generate a pulse wave with a frequency that varies sinusoidally. Here's a sample code snippet for the function:
function y = pulse_wave(t, freq)
% Generate a pulse wave with a frequency that varies sinusoidally
% t: Current time (input from Clock block)
% freq: Sinusoidal frequency input (in Hz)
T = 1 / freq; % Calculate the period
y = mod(t, T) < (T / 2); % Generate a 50% duty cycle pulse wave
end
  • Add a Clock Block to provide the current simulation time
  • Add a Sine Wave Block to generate the sinusoidal frequency variation. Configure its parameters: Amplitude: 500 (modulation range of ±500 Hz), Bias: 1000 (base frequency of 1000 Hz) and Frequency: (2*pi* 0.1) (0.1 Hz modulation speed)
  • Connect the output of the Clock block to the first input of the MATLAB Function block.
  • Connect the output of the Sine Wave block to the second input of the MATLAB Function block.
By following these steps, you will create a pulse wave whose frequency varies sinusoidally between 500 Hz and 1500 Hz.
For more information on MATLAB Function block, refer to the following documentation link:
Hope this helps.
  3 件のコメント
Shubham
Shubham 2024 年 12 月 6 日
It may be due to the high frequency and the sample time of the simulation. If the sample time is not small enough to capture the high-frequency transitions accurately, the output may appear distorted.
優大
優大 2024 年 12 月 7 日
Thank you. I'll try it.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSources についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by