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!

  • $\begingroup$ You may want to consider asking on electronics.stackexchange.com $\endgroup$ – Math1000 Jun 19 '16 at 8:03
  • $\begingroup$ I think you are overthinking it. If you have a function f(t) and you want to delay it, then it's just f(t-t0). Similarly, if you want to compress it by s, then it's f(s*t). Thus, try something like rect(3*(t-0.5)). $\endgroup$ – AnonSubmitter85 Jun 19 '16 at 17:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.