rectangular basis function/ rectangular pulse

조회 수: 11 (최근 30일)
Paul
Paul 2011년 4월 7일
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