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 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Roberto Santana
am 23 Mär. 2022
Beantwortet: Star Strider
am 24 Mär. 2022
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 Kommentare
Akzeptierte Antwort
Star Strider
am 24 Mär. 2022
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Pole and Zero Locations 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!