Error Using zeros; Size inputs must be scaler

function ampData = ampMeasure(filename, N, R)
% load a signal
[x, R] = audioread(filename);
% choose a subwindow size (in samples)
N = x * .125;
% calculate how many subwindows there are in the signal
numWindows = floor(length(x)/N);
%make a multi-row column to store all the amp measurements
a = zeros(numWindows, 1);
% make a for loop that iterates once per subwindow
for i=1:numWindows
% calculate the start/end sample range based on i
startSamp = (i-1) * N + 1;
endSamp = startSamp + (N-1);
% get the RMS of this window
a(i) = rmsAmp( x(startSamp:endSamp) );
fprintf("the RMS amp of window %i is %f\n", i, a);
end
ampData = [a(i)];
end
% it says my error is on the line with a = zeros(numWindow, 1)
% I know the situation seems easy, but I don't get it??

1 件のコメント

Prasad Reddy
Prasad Reddy 2020 年 5 月 1 日
編集済み: Prasad Reddy 2020 年 5 月 1 日
Please check weather numWindow is a scalar or nor ??
what does this command produce?? thatis important.

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

回答 (1 件)

Walter Roberson
Walter Roberson 2020 年 5 月 1 日

0 投票

N = x * .125; should be
N = floor(length(x) * .125);

カテゴリ

ヘルプ センター および File ExchangeMeasurements and Feature Extraction についてさらに検索

質問済み:

2020 年 5 月 1 日

回答済み:

2020 年 5 月 1 日

Community Treasure Hunt

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

Start Hunting!

Translated by