Clear Filters
Clear Filters

Error using stem X must be same length as Y.

67 views (last 30 days)
Im plotting a Discrete time signal at matlab and im getting this error "Error using stem
X must be same length as Y."
close all;
clear all;
clc;
clf;
AM = 19390128
Sum = mod(AM,9)
n1 = -2:1:4;
s1 = size(n1);
x1 = Sum*ones(s1);
n2 = 4:1:10;
x2 = 0;
n3 = 10:1:20;
s3 = size(n3);
i = n3 + n3;
x3 = sqrt(i);
n = [n1,n2,n3];
x = [x1,x2,x3];
stem(n,x,)
grid
Could you help me maybe and tell me what's wrong?

Accepted Answer

cr
cr on 21 Nov 2022
The lengths of x and n are different, 19 and 25. Plotting requires them to be equal.
I think you want to do
x2 = zeros(size(n2));
rather than x2 = 0;

More Answers (0)

Categories

Find more on Line Plots 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!