Adding a pulse every 0.5 seconds

조회 수: 1 (최근 30일)
Ashlynn Gallagher
Ashlynn Gallagher 2020년 9월 19일
댓글: VBBV 2020년 11월 25일
Hi,
I'm trying to add a pulse every 0.5 seconds (0.5 seconds separation between pulses), but I'm not sure where I'm going wrong.
Here's my code so far:
t0 = 0; % initial time
tf = 4; % final time
dx = (1/1349.9); % step size
time = [t0:dx:tf]; % time array for excitation
n = int16((tf-t0)/dx); % number of samples
du = 0.5; % separation length in seconds
num_pulses = 10; % number of pulses
u = zeros(n); % empty array for neural excitation value
u_1 = excitation_value('153us'); % neural excitation value from dictionary for a given pulse width
for p = 1:num_pulses
for i = 1:n
u = u + u_1(i*du);
end
end
  댓글 수: 3
Ashlynn Gallagher
Ashlynn Gallagher 2020년 9월 24일
Hi, 'excitation_value' is a dictionary I made that stored the already calculated excitation values that correspond to a given pulse width. The pulse width that I'm using here is 153us and this has some excitation value that I already calculated beforehand that is stored in the dictionary so my overall goal is to plot the excitation values for 10 pulses with a separation of 0.5s between pulses
VBBV
VBBV 2020년 11월 25일
u_1 = 153e-06; % excitation_value('153us'); is 153 microseconds
for p = 1:num_pulses
for i = 1:n
u(i) = u(i) + u_1*du;
end
end

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

답변 (1개)

Nomit Jangid
Nomit Jangid 2020년 9월 22일
There are few things i'd like to suggest
  • "zeros(n)" functions returns an n-by-n matrix of zeros.(not array)
  • MATLAB does not have any inbuilt function "excitation_value"
  • Assuming pulse is generating in every 0.5 sec, there should be 2*60*60 pulses every hour.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by