Error using stem X must be same length as Y.

조회 수: 51 (최근 30일)
ANGELOS-VASILEIOS MANTZOUKAS
ANGELOS-VASILEIOS MANTZOUKAS 2022년 11월 21일
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?

채택된 답변

cr
cr 2022년 11월 21일
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;

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Stem Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by