plotting a signal which has two equations
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am trying to plot this signal whose eqaution differs according to time



I have created this code but I do not know if it is the right way to do it and how get the values of S_if from if statment to plot it
f0=24*10^8;
B=10^6;
T_sweep=2*10^-3;
fmin=f0-0.5*B;
fmax=f0+0.5*B;
t=0:10^-3:500*10^-3;
r=250;
vt=40;
tao=2*(r-vt*t);
gamma=B/T_sweep;
At=1;
Ar=1;
t_telda=rem(t,T_sweep);
for n=1:250
if (t>=2*n*T_sweep) & (t<(2*n+1)*T_sweep)
S_if=0.5*At*Ar*cos(2*pi*gamma*r*t_telda+2*pi*fmin*tao);
elseif (t>=(2*n+1)*T_sweep) & (t<2*(n+1)*T_sweep)
S_if=0.5*At*Ar*cos(2*pi*gamma*r*t_telda-2*pi*fmax*tao);
end
end
plot(t,S_if)
0 commentaires
Réponses (1)
Torsten
le 12 Jan 2023
Modifié(e) : Torsten
le 12 Jan 2023
None of the two if conditions is satisfied for your t-array. Thus the array S_if does not exist after the for-loop - even if you change the code to
f0=24*10^8;
B=10^6;
T_sweep=2*10^-3;
fmin=f0-0.5*B;
fmax=f0+0.5*B;
t=0:10^-3:500*10^-3;
r=250;
vt=40;
tao=2*(r-vt*t);
gamma=B/T_sweep;
At=1;
Ar=1;
for n=1:250
t_telda=rem(t(n),T_sweep);
if (t(n)>=2*n*T_sweep) & (t(n)<(2*n+1)*T_sweep)
S_if(n)=0.5*At*Ar*cos(2*pi*gamma*r*t_telda+2*pi*fmin*tao(n));
elseif (t(n)>=(2*n+1)*T_sweep) & (t(n)<2*(n+1)*T_sweep)
S_if(n)=0.5*At*Ar*cos(2*pi*gamma*r*t_telda-2*pi*fmax*tao(n));
end
end
plot(t,S_if)
0 commentaires
Voir également
Catégories
En savoir plus sur Polar Plots 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!