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:
Time Shifting, time scaling.... help!!!

Subject: Time Shifting, time scaling.... help!!!

From: Animesh Pandey

Date: 30 Jan, 2011 13:03:03

Message: 1 of 2

%%
t = -10 : 0.001 : 10;
x = 0.*(t<-2) + (-4-(2.*t)).*(t>=-2 & t<0) + (-4+(3.*t)).*(t>=0 & t<4) + (16-(2.*t)).*(t>=4 & t<8) + 2.*(t>=8);
hold on
plot(t, x, 'r')
plot(t+1, x.*3, 'c')
plot(4.*t, x./2, '--m')
plot((t-1)./2, -2.*x, ':b')
grid on
hold off
%%

I have to plot
3x(t +1), (1/2) x(4t), -2x((t-1)/2)

Amplitude and Time scaling is correct (do tell me if anything is wrong) here but Time scaling is always wrong.
Could you help me in plotting with correct time scaling ?
I wish to know if there is shorter way to do it, 'cause I know if I replace 't' with t+1 or t-1, then I will get correct answer.
:\
thanks

Subject: Time Shifting, time scaling.... help!!!

From: Matt J

Date: 30 Jan, 2011 16:12:03

Message: 2 of 2

How about as follows?

t = -10 : 0.001 : 10;
x =@(t) 0.*(t<-2) + (-4-(2.*t)).*(t>=-2 & t<0) + (-4+(3.*t)).*(t>=0 & t<4) + (16-(2.*t)).*(t>=4 & t<8) + 2.*(t>=8);

hold on
plot(t, x(t), 'r')
plot(t, x(t+1).*3, 'c')
plot(t, x(4*t)./2, '--m')
plot(t, -2*x((t-1)/2) , ':b')
grid on
hold off

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