I have created a code to graph a function, but I want to repeat 10 times that signal every 3 sec in time in the graph, so it looks like a periodic signal, any ideas how?
4 ビュー (過去 30 日間)
古いコメントを表示
This is the code I have so far
A = 2
t = linspace(-2, 2, 1000);
a = exp(-0.5*t)
y = A*a.*(sin(2*pi*3*t)) .* (ustep(t+1)-ustep(t-1))
plot(t, y, 'LineWidth', 2)
xlabel('t');
ylabel('y');
title('L2E1');
grid on;
0 件のコメント
採用された回答
Star Strider
2022 年 3 月 24 日
I do not understand the units if ‘t’ so I have no idea how this corresponds to the ‘10 times every 3 sec’ requirement. I will defer to you to determine that.
This should get you started —
ustep = @(t) t>0;
A = 2;
t = linspace(-2, 2, 1000);
a = exp(-0.5*t);
y = A*a.*(sin(2*pi*3*t)) .* (ustep(t+1)-ustep(t-1));
figure
plot(t, y, 'LineWidth', 2)
xlabel('t');
ylabel('y');
title('L2E1');
grid on;
env = envelope(y, 21, 'analytic'); % Signal Envelope
Lv = env > min(env); % Extract Signal Boundaries
repeats = 10;
yv = repmat(y(Lv), 1, repeats); % Replicate Signal
tv = (0:numel(yv)-1) * (t(2)-t(1)); % Create Corresponding Time Vector
figure
plot(tv, yv)
grid
xlim([min(tv) max(tv)])
title(sprintf('Repeats = %d, Time interval: %.0f to %.1f Units', repeats, min(tv), max(tv)))
.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Pole and Zero Locations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!