rectangular basis function/ rectangular pulse

11 次查看(过去 30 天)
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 个评论
Jarrod Rivituso
Jarrod Rivituso 2011-4-7
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?

请先登录,再进行评论。

回答(2 个)

Matt Fig
Matt Fig 2011-4-7
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 2011-4-7
if you have the symbolic toolbox:
doc dirac

类别

Help CenterFile Exchange 中查找有关 Mathematics 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by