Issue plotting stem function
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Ismael Gilles Durand
le 7 Juin 2022
Réponse apportée : KSSV
le 7 Juin 2022
I am trying to plot a discrete function Xn using the stem function and also plot a continuous function Xt on the same figure over the same interval.
X=@(t) 3*sin(100*pi*t);
t=linspace(0,0.05);
Xn=3*sin(pi*n/3);
n=linspace(0,0.035); %%This line is trying to match the number of elements in N
N=[0 2.6 2.6 0 -2.6 -2.6 0];
figure(1);
plot(t,X(t));
grid on;
hold on;
stem(N,Xn);
axis([0 0.05 -3 3])
0 commentaires
Réponse acceptée
KSSV
le 7 Juin 2022
X=@(t) 3*sin(100*pi*t);
t=linspace(0,0.05);
%
n=linspace(0,0.035); %%This line is trying to match the number of elements in N
N=[0 2.6 2.6 0 -2.6 -2.6 0];
Xn=3*sin(pi*N/3);
figure(1);
plot(t,X(t));
grid on;
hold on;
stem(N,Xn,'*-r');
axis([0 0.05 -3 3])
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Annotations 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!