Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
A problem in plotting a figure !!!!

Subject: A problem in plotting a figure !!!!

From: Animesh Pandey

Date: 21 Feb, 2011 11:01:26

Message: 1 of 2

t = -4 : 0.01 : 4;
r = @(t) t.*(t>=0).*(t>=0 & t<=1);
h = @(t) (t>=0).*(t>=0 & t<=1);
i = @(t) (t==0);
x = @(t) r(t+2) + 2*h(t+1) + h(t) + -r(t-1);
plot(t, x(t), 'r'), grid on

In this question I am getting two impulses at t = -1 and t = 0 above the edge at x = 2 , but I don't need those pulses.
Can you suggest a better way to plot the figure or may be a way to remove the impulses ???

Please help !!!!

Subject: A problem in plotting a figure !!!!

From: ImageAnalyst

Date: 21 Feb, 2011 14:03:15

Message: 2 of 2

On Feb 21, 6:01 am, "Animesh Pandey" <apanimesh...@gmail.com> wrote:
> t = -4 : 0.01 : 4;
> r = @(t) t.*(t>=0).*(t>=0 & t<=1);
> h = @(t) (t>=0).*(t>=0 & t<=1);
> i = @(t) (t==0);
> x = @(t) r(t+2) + 2*h(t+1) + h(t) + -r(t-1);
> plot(t, x(t), 'r'), grid on
>
> In this question I am getting two impulses at t = -1 and t = 0 above the edge at x = 2 , but I don't need those pulses.
> Can you suggest a better way to plot the figure or may be a way to remove the impulses ???
>
> Please help !!!!

--------------------------------------------------
Here's one way. Just clip the values to 2:


xActual = x(t);
xActual(xActual>2) = 2; % Clip to 2
plot(t, xActual, 'r'), grid on

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us