I need to repeat a periodic signal
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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
0 Kommentare
Antworten (2)
Image Analyst
am 8 Nov. 2023
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.
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.
0 Kommentare
Walter Roberson
am 8 Nov. 2023
Hint:
syms t
F(t) = piecewise(-2 <= t & t < 0, 1, 0 <= t & t < 1, 2, 1 <= t & t < 2, 3)
fplot(F, [-10 10]); ylim([-1 4])
G = F(mod(t,4)-2)
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 Kommentare
Paul
am 11 Nov. 2023
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
am 11 Nov. 2023
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])
Siehe auch
Kategorien
Mehr zu Number Theory finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!