フィルターのクリア

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 Center および File ExchangeMultirate Signal Processing についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by