필터 지우기
필터 지우기

Need Help..............Error using stem (line 43) X must be same length as Y.

조회 수: 9 (최근 30일)
praveen sebastian
praveen sebastian 2021년 1월 13일
이동: DGM 2022년 10월 30일
close all;
clear all;
clc;
fs=6000;
t=0:0.001:.1;
t1=0:1/fs:1;
f1=200;
f2=1000;
f3=1500;
f4=2500;
xa1=2*sin(f1*pi*t);
xa2=3*cos(f2*pi*t);
xa3=.5*sin(f3*pi*t);
xa4=sin(f4*pi*t);
xa11=2*sin(f1*pi*t);
xa22=3*cos(f2*pi*t);
xa33=.5*sin(f3*pi*t);
xa44=sin(f4*pi*t);
xa=xa1-xa2-xa3+xa4;
xaa=xa11-xa22-xa33+xa44;
subplot(2,1,1);
plot(t,xa);
ylabel('Amplitude');
xlabel('time t')
title('original wave')
hold on;
subplot(2,1,2);
stem(t1,xaa);
ylabel('Amplitude');
xlabel('time t')
title('Wave sampled at Fs=6000')
hold on;
  댓글 수: 3
MOHAMUD abukar
MOHAMUD abukar 2022년 10월 30일
이동: DGM 2022년 10월 30일
close all;
clear all;
clc;
n=-2:2;
x=[0.5, 2, -1.5, 2.5, 4, 3, -2, 3.5, 2, 0.5];
subplot(2,1,1);
stem(n,x);
xlabel('Time Sample');
ylabel('Amplitude');
title('Original sequence');
axis([-5,5,-5,8]);
m=n-3;
subplot(2,1,2);
stem(m,x);
xlabel('Time Sample');
ylabel('Amplitude');
title('Time shifted signal');
axis([-5,5,-5,8]);
DGM
DGM 2022년 10월 30일
이동: DGM 2022년 10월 30일
How many elements are there in n? How many are in x? Are they equal? Why aren't they equal? Since they're all constants asserted arbitrarily, you're the only person who can answer that question.

댓글을 달려면 로그인하십시오.

채택된 답변

Stephan Ciobanu
Stephan Ciobanu 2021년 1월 13일
xaa is an 1x101 array and t1 is 1x6001 array.
Put t1 instead of t when you define xa11,xa22,xa33,xa44
xa11=2*sin(f1*pi*t1);
xa22=3*cos(f2*pi*t1);
xa33=.5*sin(f3*pi*t1);
xa44=sin(f4*pi*t1);

추가 답변 (1개)

Alan Stevens
Alan Stevens 2021년 1월 13일
Either you want
stem(t,xaa);
or you want to use t1 in the definitions of xa11, xa22 etc.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by