Assignment has more non-singleton rhs dimensions than non-singleton subscripts

9 ビュー (過去 30 日間)
David Costa
David Costa 2018 年 3 月 2 日
回答済み: Jan 2018 年 3 月 2 日
Hello, can anyone help me with this error with the code shown bellow?
if true
samplingRate = 11025;
%transform the signal to the frequency domain.
%fourierData = fft(data,length(data));
%magFour = abs(fourierData);
totalFileTimeInMSec = (length(data) / samplingRate)*100;
frameLengthInMSec = 1;
% calculate the number of frames
numberOfFrames = totalFileTimeInMSec / frameLengthInMSec;
numberOfFrames = floor(numberOfFrames);
% calculate the size of each frame in the data array.
frameSize = samplingRate * frameLengthInMSec / 100;
%initialize the frames.
% frames = zeros(numberOfFrames,frameSize);
% frame = zeros(1,frameSize);
frames = numberOfFrames;
frame = frameSize;
% copy the data from the signal to the frames.
startIndex = 1;
endIndex = frameSize;
for frameM = 1:1:numberOfFrames
frame = data(startIndex:endIndex,1);
startIndex = startIndex + frameSize;
endIndex = endIndex +frameSize;
frames(frameM,:) = frame.';
end
  4 件のコメント
Stephen23
Stephen23 2018 年 3 月 2 日
You define frames to be a single scalar number:
frames = numberOfFrames;
but you seem to be indexing into it as if it were an array.
David Costa
David Costa 2018 年 3 月 2 日
How can I fix it?

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

回答 (1 件)

Jan
Jan 2018 年 3 月 2 日
Why did you change
% frames = zeros(numberOfFrames,frameSize);
to
% frame = zeros(1,frameSize);
frames = numberOfFrames;
frame = frameSize;
The first was working, and adding more definitions, partially as comment, overwriting the former one, is confusing only, obviously.

カテゴリ

Help Center および File ExchangeDescriptive Statistics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by