rectangular basis function/ rectangular pulse

11 visualizaciones (últimos 30 días)
Paul
Paul el 7 de Abr. de 2011
How do I create a function that is 1 over a certain period and 0 everywhere else. For example:
I need to integrate over a line split into segments and than x values are the midpoints of these segments. I have already done this by writing I = 1:N; X = delta*(I-0.5); where delta is the width of each segment. So i need to create a function that is 1 from X(i)-delta/2 <= X(i) <= X(i)+delta/2 but 0 everywhere else and be able to multiply this by an Amplitude function so that the Amplitude is the height of the pulse I am trying to create.
Any help would be much appreciated (its a Method of Moments EM problem if that helps)
  1 comentario
Jarrod Rivituso
Jarrod Rivituso el 7 de Abr. de 2011
Can you comment a bit more on exactly the output that you want? You state that you want to multiply this by "an amplitude function" and that you want to "create a function that is 1 from...". Do you really want to create a MATLAB function, or are you trying to create other vectors?

Iniciar sesión para comentar.

Respuestas (2)

Matt Fig
Matt Fig el 7 de Abr. de 2011
Your description is a little unclear. Here is a function which will do something similar to what your first sentence asks.
function Y = squarepulse(X,center,delta)
Y = ones(size(X));
idx = X<(center-delta) | X>(center+delta);
Y(idx) = 0;
Now from the command line:
x = -10:.01:10; center = 5; delta = .5;
plot(x,squarepulse(x,center,delta))
axis([-15 15 -1 2])

bym
bym el 7 de Abr. de 2011
if you have the symbolic toolbox:
doc dirac

Categorías

Más información sobre Mathematics en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by