MATLAB: How to plot a continuous signal

#plot signal

I want to plot x(t) = cos(200*pi*t*u(t)) and define u(t) seprately and then plot x(-t),x(t/3)
i wrote this
x = @(t) cos(200*pi*t*u(t));
t = linspace(-1, 1);
figure(1)
plot(t, x(t))
grid
function y = u(x)
y=0;
if x>=0
y=1;
end
end

Best Answer

This should get you started:
u = @(t) t>=0;
x = @(t,u) cos(200*pi*t.*u(t));
t = linspace(-1, 1);
figure(1)
plot(t, x(t,u))
grid
Extending that:
u = @(t) t>=0;
x = @(t,u) cos(200*pi*t.*u(t));
t = linspace(-1, 1);
figure(1)
plot(t, x(t,u))
hold on
plot(t, x(-t,u))
plot(t, x(t/3,u))
hold off
grid
Experiment to get different results.