I need to repeat a periodic signal
7 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (2 件)
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.
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 件のコメント
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)
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 件のコメント
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
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 Center および File Exchange で Number Theory についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!