Plotting cycles of signal

1 次查看(过去 30 天)
Ben Hamill
Ben Hamill 2019-11-15
回答: Raunak Gupta 2019-11-18
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 ≤ π

回答(1 个)

Raunak Gupta
Raunak Gupta 2019-11-18
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]);

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by