I need to repeat a periodic signal

7 次查看(过去 30 天)
ALOUI
ALOUI 2023-11-8
The function is
f(t) = -t/2 if -2<=t<0
f(t) = t if 0<=t<1
f(t) = 1 if 1<=t<2
The periode is 4
and it has to be repeated from -10 to 10

回答(2 个)

Image Analyst
Image Analyst 2023-11-8
This looks like a homework problem. If you have any questions ask your instructor or read the link below to get started:
Obviously we can't give you the full solution because you're not allowed to turn in our code as your own.
Hint: linspace to generate t, and repmat to make additional copies of a vector.
Use masking to get the ranges of indexes for t and don't use (t) when assigning f, use the mask, like
t = linspace(..................); % You finish it
f = zeros(1, numel(t)); % Initialize
indexesToAssign = (-2 <= t) & (t < 0); % Get logical vector (mask) of where these indexes are.
f(indexesToAssign) = -t/2;
% Similar for the two other ranges.

Walter Roberson
Walter Roberson 2023-11-8
Hint:
syms t
F(t) = piecewise(-2 <= t & t < 0, 1, 0 <= t & t < 1, 2, 1 <= t & t < 2, 3)
F(t) = 
fplot(F, [-10 10]); ylim([-1 4])
G = F(mod(t,4)-2)
G = 
fplot(G, [-10 10]); ; ylim([-1 4])
This tells us that if you can construct f(t) for one period of t, then you can extend it to an indefinite number of periods using mod
  3 个评论
Paul
Paul 2023-11-11
I don't think the expression for G is correct. G should overlay F in the range -2<t<2.
syms t
F(t) = piecewise(-2 <= t & t < 0, 1, 0 <= t & t < 1, 2, 1 <= t & t < 2, 3);
G(t) = F(mod(t,4)-2);
figure
fplot([G F],[-10 10],'ShowPoles','off')
ylim([0 4])
Walter Roberson
Walter Roberson 2023-11-11
Good catch, @Paul
syms t
F(t) = piecewise(-2 <= t & t < 0, 1, 0 <= t & t < 1, 2, 1 <= t & t < 2, 3);
G(t) = F(mod(t+2,4)-2);
figure
fplot([G F],[-10 10],'ShowPoles','off')
ylim([0 4])

请先登录,再进行评论。

类别

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

产品


版本

R2012b

Community Treasure Hunt

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

Start Hunting!

Translated by