위치 2의 인덱스가 배열 경계를 초과합니다. 어떻게 해결하나요?
38 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Joye
am 20 Jun. 2024
Verschoben: Angelo Yeo
am 28 Jun. 2024
% Get info of recording dates
RecDates = readtextfile('Rec_dates.txt');
line1 = deblank(RecDates(1,:));
SurgeryDate = line1(9:end)
%SurgeryDate = input('Type the surgery date (e.g. 20220311)','s');
SurgeryDate2 = [SurgeryDate,'-000000-000'];
SurgeryDate3 = datenum(SurgeryDate2,'yyyymmdd-HHMMSS-FFF');
a=size(RecDates);
nRec = a(1)-1;
for n=1:nRec
line = deblank(RecDates(n+1,:));
Rec(n) = line(end);
end
% Get average amplitude and entropy envelopes of the 10+ model songs
Models = ls('ModelSongs4xcorr/*.wav');
clear Ampl Entr
for n=1:length(Models(:,1))
SoundFile = ['ModelSongs4xcorr/',deblank(Models(n,:))];
[Sound, Fs]=audioread(SoundFile);
if length(Sound(1,:))>1
Sound = Sound(:,1);
end
[SAPFeatures] = GetSAPFeatures(Sound,Fs);
Ampl{n} = SAPFeatures.Amplitude;
Entr{n} = SAPFeatures.Entropy;
end
위치 2의 인덱스가 배열 경계를 초과합니다.
오류 발생: SingRate_SongSort2_NHpC (line 22)
for n=1:length(Models(:,1))
0 Kommentare
Akzeptierte Antwort
Angelo Yeo
am 22 Jun. 2024
올려주신 스크립트를 보았을 때,
Models = ls('ModelSongs4xcorr/*.wav');
라는 명령어를 통해 "ModelSongs4xcorr" 폴더 안의 wav 파일의 정보를 받아오려고 하는 것으로 보입니다. 그러나,
for n=1:length(Models(:,1))
이라는 스크립트에서 Models에 접근할 때 이 Models가 빈 벡터가 되면 말씀하신 "위치 2의 인덱스가 배열 경계를 초과합니다." 라는 에러가 발생할 수 있습니다. 예를 들면 아래와 같은 상황이 되겠습니다.
Models = [];
Models(:,1)
1 Kommentar
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu 오디오와 비디오 finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!