How to generate a single pulse sine wave

조회 수: 8 (최근 30일)
Nupur
Nupur 2024년 8월 20일
답변: Anurag Ojha 2024년 8월 20일
I want to generate a single pulse sine wave which starts at 20 sec and goes to zero after one full period. The frequency of of the pulse should be 0.5 hz and the amplitude 1 and the sampling rate 0.05 sec.
Please let me know.

채택된 답변

Anurag Ojha
Anurag Ojha 2024년 8월 20일
Hi Nupur
To generate a single pulse sine wave with the given specifications, you can refer to following MATLAB code:
% Define the time vector
t = 0:0.05:40;
% Generate the sine wave
f = 0.5; % Frequency in Hz
A = 1; % Amplitude
x = A*sin(2*pi*f*t);
% Create the pulse
pulse_start = 20; % Start time of the pulse in seconds
pulse_duration = 1/f; % Duration of the pulse in seconds
pulse_end = pulse_start + pulse_duration; % End time of the pulse in seconds
pulse = x.*(t >= pulse_start & t <= pulse_end);
% Plot the pulse sine wave
plot(t, pulse)
xlabel('Time (s)')
ylabel('Amplitude')
title('Single Pulse Sine Wave')

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Simulink에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by