Clear Filters
Clear Filters

Plot with specific x value

4 views (last 30 days)
Tu Nguyen
Tu Nguyen on 2 Mar 2022
Commented: Tu Nguyen on 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

Accepted Answer

Cris LaPierre
Cris LaPierre on 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

More Answers (0)

Categories

Find more on Inertias and Loads in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!