Error using stem X must be same length as Y.

48 ビュー (過去 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;
  1 件のコメント
ANGELOS-VASILEIOS MANTZOUKAS
ANGELOS-VASILEIOS MANTZOUKAS 2022 年 11 月 21 日
yep it worked, thank you

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by