I want to be able to preallocate multiple iterations of a matrix inside a for loop i.e. matrix(count)=zeros(L:1), matlab keeps telling me dimensions don't match. Is there a syntax way to do this? I was thinking maybe change to an if else if.....
Afficher commentaires plus anciens
if true
% code
end
Fs=2000;
nBits=8;
nChannel=1;
devID=1;
L=4000;
disp('press 1 for training dictionary')
result=input(':');
if result==1
count=input('number of refernce files to make(max number 5): ')
if count>5
disp('I told you not to go higher than 5!!!')
else
dictionmatrix1=zeros(L:1);<---I want to preallocate based on the count
dictionmatrix2=zeros(L:1);
dictionmatrix3=zeros(L:1);
dictionmatrix4=zeros(L:1);
dictionmatrix5=zeros(L:1);
end
for count=n:-1:1
ISAC=audiorecorder(Fs,nBits,nChannel,devID);
disp('Please makes sure to speak clearly and at the same distance from the microphone')
disp('for all reference samples. Recording in....')
for time=3:-1:0
x=time
pause(1);
disp(x);
end
disp('Start Recording');
recordblocking(ISAC,2);
disp('Processing');
testarray=getaudiodata(ISAC);
a=zeros(L:1);
a(1:L)=testarray(1:L);
dictionmatrix(count)=a;%<------I want to save to the preallocated matrix
end end
if true
% code
end
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!