MATLAB: How i plot 2 equations at different period in one graph

engineering

x(t)=1.414*e^(-t)*sin(t+0.785) 0<t<pi x(t)=1.414*e^(-t)*sin(t+0.785)-e^(-t+pi)*sint t>pi

Best Answer

Try this:
x = @(t) (sqrt(2)*1.414*exp(-t).*sin(t+0.785)).*((0 < t) & (t < pi)) + (sqrt(2)*exp(-t).*sin(t+0.785)-exp(-t+pi).*sin(t)).*(t > pi);
t = linspace(0, 2*pi, 500);
figure(1)
plot(t, x(t))
grid
Related Question