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?

조회 수: 2 (최근 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;

채택된 답변

Star Strider
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개)

카테고리

Help CenterFile Exchange에서 Graph and Network Algorithms에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by