Borrar filtros
Borrar filtros

Plotting cycles of signal

1 visualización (últimos 30 días)
Ben Hamill
Ben Hamill el 15 de Nov. de 2019
Respondida: Raunak Gupta el 18 de Nov. de 2019
Hi, I am relatively unexperienced with MATLAB but how do i plot any number of cycles of the following signal;
z(t) = 0 if − π ≤ t < 0
3 if 0 ≤ t ≤ π

Respuestas (1)

Raunak Gupta
Raunak Gupta el 18 de Nov. de 2019
Hi,
For plotting the function mentioned in the question you may use square wave as it will replicate your requirements. I have written an example below which plots the function in range [-16π,16π]. You may find it helpful.
% This particular t will plot 16 cycles
% t can be changed accordingly for plotting particular number of cycles
t = -16*pi:0.02:16*pi;
x = 3*square(t); % Period of the wave is 2*pi
x = x.*(x>=0); % converting negative cycle to zero as per function requirement
plot(t/pi,x); % Plotting t/pi for better understanding
xticks(-16:16);
xlabel('t / \pi')
ylim([-1,4]);
xlim([-17,17]);

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by