MATLAB Answers

Creating a rectangular pulse

417 views (last 30 days)
I can create an rectangular pulse with code
b1 = 5;
a1 = 5;
x = -10:0.01:10;
% a pulse function
f = @(xi,a,b) a*rectpuls(xi,b);
% plot to
plot(x,f(x,a1,b1),'b--');
title(['Rectangular Pulse']);
xlabel('Time');
ylabel('Amplitude');
I now want to move this pulse, to start from x = -2 and end at x=+3, i.e. not have it centred around zero?
Any idea how to make it so?

  0 Comments

Sign in to comment.

Accepted Answer

Mischa Kim
Mischa Kim on 12 Oct 2017
captain, how about
plot(x,f(x-0.5,a1,b1),'b--');

  1 Comment

captainmariah
captainmariah on 12 Oct 2017
Did not think about moving the x vector. Many thanks!

Sign in to comment.

More Answers (0)

Sign in to answer this question.


Translated by