Delaying signals in Matlab

1.1k Views Asked by At

I'm new to MATLAB and have a question that I need help on:

The problem I have is to plot the simple signals: a 1Hz Sine wave, a standard rectangle function and a standard triangle function

Here is my code for the Sine Wave:

t = [-5:.01:5]; %time interval A = 1; %amplitude f = 1; %frequency n = 0.5; %delay amount y = A*sin(2*pift); plot(t,y) title('1 Hz Sine Wave') ylabel ('Amplitude') xlabel ('t');

Similarly for the standard rectangle function

function y = rect(t) y = (sign(t+0.5)-sign(t-0.5) > 0); end t = [-5:0.1:5]; %time interval y = rect(t); plot(t,y) title('Standard Rectangular Function') ylabel ('y(t)') xlabel ('t')

and lastly, the triangle function:

function y=triangl(t) y = (1-abs(t)).(t>=-1).(t<1); end t = [-5:0.1:5]; %time interval y = triangl(t); plot(t,y) title('Standard Triangle Function') ylabel ('y(t)') xlabel ('t')

As you can see, the code itself is not very complex at all, but in the next step, I am to time delay each one by 0.5 seconds and plot each of the signals with a time scaling compression of 3. I have looked around to try and find some sort of explanation on how to go about performing these kinds of signal operations in MATLAB, but unfortunately I haven't found anything that is particularly good or detailed that would serve to help me understand how to solve this. Would anyone be able to help? Thanks so much in advanced for your help, I really appreciate it!