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 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Roberto Santana
le 23 Mar 2022
Réponse apportée : Star Strider
le 24 Mar 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 commentaires
Réponse acceptée
Star Strider
le 24 Mar 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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Pole and Zero Locations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!