How to create mono phasic square waves with certain amplitude, pulse width and frequency for a certain time period

조회 수: 4 (최근 30일)
Hi,
I would like to create an output signal for my constant current stimulator. I would like to send square pulses with certain amplitude, pulse width and frequency for a certain time period.
For example: I want to send a pulse train (pulse width = 100µs) for 400ms in 100Hz.
What would be the best approach for this?
Thanks!

채택된 답변

Bjorn Gustavsson
Bjorn Gustavsson 2022년 6월 11일
you could use square - for details check the help and documentation of that function.
HTH.
  댓글 수: 2
Evrim Yilmaz
Evrim Yilmaz 2022년 6월 11일
Thanks, this is the first thing I did. But, I can't set the pulse width with this function.
Evrim Yilmaz
Evrim Yilmaz 2022년 6월 11일
I got it, silly me.
clc
clear all
SR = 10000; % SR: sampling rate, constant
A = 0.5; % A: amplitude, mAmper
F = 100; % F: frequency, Hz
TW = 0.1; % TW: train width, second
PW = 0.0001; % PW: pulse width, second (50µs)
i = 1;
SW(i) = (TW(i) / F(i))- PW(i); % SW: space width (interpulse duration)
CT(i) = PW(i) + SW(i); % CT: cycle time
DC(i) = (PW(i) / CT(i)) *100; % DC: Duty cycle (% of ON) in a cycle
t = 0:1/SR:TW(i);
y = A(i)*((1 + square(pi*F(i)*t,DC(i)))/2);
plot(t,y)
xlim([0 t(1,end)]) % last element in t
ylim([0 A(i)*1.2]);

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by