Periodic function. How would I make this function repeat itself for, let's say, -1 to 3 seconds or something?
10 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
clear;clc;
Vm =1 ; % Amplitude of signal T= 1 ; % Period
syms t;
v1 = Vm*sin((4*pi*t)/T);
v2= 2*Vm*sin((4*pi*t)/T);
v = piecewise(0<=t<=T/2,v1,T/2<=t<=T,v2);
figure;
fplot (t,v) ;
grid on xlabel('time s ');
ylabel('Voltage V ');
title('v(t) vs t ');
legend('v ')
1 commentaire
Image Analyst
le 24 Oct 2019
Original question in case dummy erases this one too:
Periodic function. How would I make this function repeat itself for, let's say, -1 to 3 seconds or something?
clear;clc;
Vm =1 ; % Amplitude of signal T= 1 ; % Period
syms t;
v1 = Vm*sin((4*pi*t)/T);
v2= 2*Vm*sin((4*pi*t)/T);
v = piecewise(0<=t<=T/2,v1,T/2<=t<=T,v2);
figure;
fplot (t,v) ;
grid on xlabel('time s ');
ylabel('Voltage V ');
title('v(t) vs t ');
legend('v ')
Réponses (1)
Geoff Hayes
le 20 Avr 2019
A for loop could be used. Perhaps something like
for t=-1:3
% use t in your code
end
2 commentaires
Geoff Hayes
le 21 Avr 2019
well it would be up to you to decide how to use t in your code so that you get a different answer on each iteration of the loop.
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements 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!