![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/284467/image.jpeg)
Info
This question is closed. Reopen it to edit or answer.
I've been trying to plot the following figure for t, but I keep getting it wrong.
2 views (last 30 days)
Show older comments
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/283062/image.png)
Writing it in terms of singularity function would be;
y(t) = 2u(t) - u(t-2) + u(t-4) - r(t-6)
Matlab;
function [y1] = y1(t)
y1 = y1 = 2*(t>=0 & t<2)-1*(t>=2 & t<4)+1*(t>=4 & t<6)+ (2)*(-t/3).*(t>=6 & t<8);
end
t = -10:0.01:10;
Y1 = y1(t);
plot(t,Y1); ylabel('y1(t)')
For some reason the unit step and ramp signals are always referring to the origin. And my ramp signal starts at -4 which I have no idea why.
0 Comments
Answers (1)
Rajani Mishra
on 14 Apr 2020
I have modified your code and plotted the result, Please refer below for the code:
function [y1] = y1(t)
y1 = 2*(t>=0) + -1*(t>=2) +1*(t>=4) + (2)*(-t/3).*(t>=6);
end
Below is the result of the above code :
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/284467/image.jpeg)
0 Comments
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!