Vector dimensions not right

조회 수: 2 (최근 30일)
Nathan Jaqua
Nathan Jaqua 2019년 9월 29일
답변: KALYAN ACHARJYA 2019년 9월 29일
trying to added the cosine wave as a noise vector to the pwelch command, but the software says 'Matrix dimensions must agree'. What's wrong with my code?
f2 = 5000;
A2 = 0.25;
t2 = 0:1/f2:5-1/f2;
x2 = A2*cos(2*pi*f2*t)+randn(size(t2));
[y,Fs]=audioread('doorbell.wav');
[pxx,f] = pwelch(x2,[],[],[],Fs);
plot(f,10*log10(pxx)); xlabel('Frequency (Hz)'); ylabel('PSD (dB/Hz)');
  댓글 수: 1
Walter Roberson
Walter Roberson 2019년 9월 29일
What size is t ? You do not show us the initialization for it.

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

채택된 답변

KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 9월 29일
As already @Walter sir specified, you did not provide us the "t" data, here I have assumed the t data as same as t2
Please assign any "t" data as you want, but ensured that the size of t and t2 must be same.
f2 = 5000;
A2 = 0.25;
t = 0:1/f2:5-1/f2;
t2 = 0:1/f2:5-1/f2;
x2 = A2*cos(2*pi*f2*t)+randn(size(t2));
[y,Fs]=audioread('doorbell.wav');
[pxx,f] = pwelch(x2,[],[],[],Fs);
plot(f,10*log10(pxx)); xlabel('Frequency (Hz)'); ylabel('PSD (dB/Hz)');
ui.png

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Parametric Spectral Estimation에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by