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.....
Show older comments
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
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!