![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/361582/image.png)
How to create a square wave pulse
227 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
How do I create a square wave pulse, I don't really mind the gap between pulses but it must go on for 10ms. I dont mind the freauency or anything I just want to know how to create a square wave pulse that happens say 3 times in the 10ms
0 commentaires
Réponses (2)
Star Strider
le 16 Sep 2020
Without the Signal Processing Toolbox:
t = linspace(0, 10E-3); % Time Vector (0 - 10ms)
f = 3/max(t); % Desired Frequency (Cycles/Timespan)
sqwv = sign(sin(2*pi*t*f)); % Signal
figure
plot(t, sqwv, 'LineWidth',1.5)
grid
ylim(ylim*1.1)
xlabel('Time (s)')
ylabel('Amplitude')
producing:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/361582/image.png)
.
0 commentaires
Ameer Hamza
le 16 Sep 2020
Modifié(e) : Ameer Hamza
le 16 Sep 2020
If you have signal processing toolbox
T = 0.01; % 10 milliseconds timeperiod, 1 square wave in 10 milliseconds
t = linspace(0, T*10, 1000);
y = square(t/T*2*pi);
plot(t, y);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/361426/image.png)
If you want to generate the waveform in Simulink, then you can use a pulse generator block and use the following settings.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/361432/image.png)
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!