MATLAB: 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)-2u(t-4)+r(-t-5) ... Since the question contains both step and ramp, how to write the code for it? Best Answer syms u(t) r(t) x(t) t0u(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. Related SolutionsMATLAB: There is error in x1(t) syms t t0u(t)=piecewise(t<t0, 0, t>=t0, 1);x1(t)=2*u(t-1)-2*u(t-3);T = 0:1/50:10;X1 = double(subs(x1(T),t0,0));plot(T, X1,'r')hold onr(t) = piecewise(t<t0, 0, t>=t0, t-t0);x2(t) = r(t-(11/3))-2*r(t-(13/3));X2 = double(subs(x2(T), t0, 0));plot(T, X2, 'b'); MATLAB: X(t) = 2*u((-t/4)+2), |t|<=10 I guess u is the unit-step function. You can try this if you have symbolic toolboxsyms tx = 2*heaviside(-t/4+2);fplot(x, [-10 10]);Without symbolic toolboxu = @(x) 1*(x>=0);t = -10:0.01:10;x = 2*u(-t/4+2);plot(t, x) Related QuestionFind intersection point between u(t) = t^2(t-1) and u = 10.How to plot something like this?Plotting unit step function
Best Answer