How to sketch the following signal? x(t)= 3u(t-10)+ 4u(-t+3)-r​(t+2)+4r(t​)-2u(-t-2)​-2r(t-3)-2​u(t-4)+r(-​t-5)

Since the question contains both step and ramp, how to write the code for it?

11 Comments

What are r and u ? Do you have any ranges?
u- step function r-ramp function Range -10 to 10
I ran the code, it says "undefined function or variable 'piecewise' " and also it shows an error in this line, u(t)=piecewise(t<t0 ,0 , t>=t0 ,1)
piecewise is a built-in function in MATLAB, it should be located in your MATLAB folder.
K.... Thanks The whole question is as follows, I would very much appreciate if you could show me how to do as the question states and pls don't forget to attach the files so that I can counter check. 1) Sketch the following signals using MATLAB
x(t)= 3u(t-10)+ 4u(-t+3)-r(t+2)+4r(t)-2u(-t-2)-2r(t-3)-2u(t-4)+r(-t-5)
Note that have to first define functions that draw unit step and unit ramp functions.
These functions should have two input parameters (scale factor and time delay amount). You have to call these unit step and ramp functions to plot x(t).
2) Sketch even and odd components of x(t)
Pls attach the output file or image. Thanks in advance.
Firstly, if piecewise gives you error, then find the code for it from internet, put it in your current directory, then run the code. You should see the code working and understand it. Next steps can be done later.

Sign in to comment.

 Accepted Answer

syms u(t) r(t) x(t) t0
u(t)=piecewise(t<t0, 0, t>=t0, 1);
r(t)=piecewise(t<t0, 0, t>=t0, t-t0);
t1=-6:0.01:10;
x(t)=3*u(t-10)+4*u(-t+3)-r(t+2)+4*r(t)-2*u(-t-2)-2*r(t-3)-2*u(t-4)+r(-t-5);
x=subs(x,{t0,t},{0,t1});
plot(t1,x)
Something like this should do it. Note that I defined the input range randomly. Hope this helps.

More Answers (0)

Categories

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!