rectangular basis function/ rectangular pulse

12 Ansichten (letzte 30 Tage)
Paul
Paul am 7 Apr. 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 Kommentar
Jarrod Rivituso
Jarrod Rivituso am 7 Apr. 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?

Melden Sie sich an, um zu kommentieren.

Antworten (2)

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

Kategorien

Mehr zu Mathematics finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by