Plot with specific x value

2 vues (au cours des 30 derniers jours)
Tu Nguyen le 2 Mar 2022
Commenté : Tu Nguyen le 2 Mar 2022
clc;
close all;
clear all;
x1= [1 2 3 4 5];
L = 2;
n = linspace(0,4,10);
m =linspace(0,10,10);
h1 = dirac(n - m*L);
idx = h1 == Inf;
h1(idx) = 1;
h2 = dirac(n-m/L);
idx = h2 == Inf;
h2(idx) = 1;
y1 = conv(x1,h1);
y2 = conv(x1,h2);
subplot(1,2,1);
stem(y1);
subplot(1,2,2);
stem(y2);
Hi all, I just want to stem y1 and y2 on x coordiante from 0 to 10. How can I do that? If I set stem(y1,[0 10]), it returns X and Y must have same dimension. Please help me
0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

Réponse acceptée

Cris LaPierre le 2 Mar 2022
Use xlim?
x1= [1 2 3 4 5];
L = 2;
n = linspace(0,4,10);
m =linspace(0,10,10);
h1 = dirac(n - m*L);
idx = h1 == Inf;
h1(idx) = 1;
h2 = dirac(n-m/L);
idx = h2 == Inf;
h2(idx) = 1;
y1 = conv(x1,h1);
y2 = conv(x1,h2);
subplot(1,2,1);
stem(y1);
xlim([0 10]) % xlim
subplot(1,2,2);
stem(y2);
xlim([0 10]) % xlim
1 commentaireAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens
Tu Nguyen le 2 Mar 2022
Thank you so much

Connectez-vous pour commenter.

Catégories

En savoir plus sur Inertias and Loads 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!

Translated by