필터 지우기
필터 지우기

error using + matrix dimension must agree

조회 수: 2 (최근 30일)
hanin t
hanin t 2023년 10월 11일
댓글: Adam Danz 2023년 10월 11일
y1=audioread('bel.wav');
var = 0.1;
N=length(y1) ;
noise_1=var.*randn(N,1);
y_1n=y1 + noise_1;
subplot(311)
plot(y_1n)
may I know why I keep getting this error:
error using +
matrix dimensions must agree
error in
y_1n=y1 + noise_1;

답변 (1개)

Dyuman Joshi
Dyuman Joshi 2023년 10월 11일
Without the data, we can only guess. And the most probable guess is that y1 is a 2D array and using length() with non-vector array results in ambiguous outputs. A better option is to use size().
Try this -
y1 = audioread('bel.wav');
var = 0.1;
N = size(y1,1);
noise_1 = var.*randn(N,1);
y_1n = y1 + noise_1;
subplot(311)
plot(y_1n)
  댓글 수: 1
Adam Danz
Adam Danz 2023년 10월 11일
☝️ +1
Slight improvement in case there is more than 1 audio channel:
noise_1 = var.*randn(size(y1));

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

카테고리

Help CenterFile Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by