How to solve error "Index exceeds the number of array elements (1)."?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Hello everyone! I am trying to make a staircase threshold with auditory stimuli. My code is pretty simple: I have 5 sounds at frequencies immerse in noise, I randomise their presentation while decreasing or increasing the SNR depending on the response of the subject.
myPitches = [500, 1000, 1500, 2000, 2500];
condition_fs = [1 2 3 4 5];
howLong = .5;
presentedPitches = [];
for condition = 1:5 % five frequencies
for trial = 1:20 % presentation for each frequency
% Random presentation of sounds at different pitches
RandPitches = randperm(5,1);
pitch = myPitches(RandPitches(condition_fs));
presentedPitches(condition_fs, trial) = pitch; % save pitches
pause(1.5)
[beep] = MakeBeep(pitch, howLong, samplingRate);
end
end
This is part of my code. The error occurs at line 5 "Index exceeds the number of array elements (1)". I can't work out what it even means and I can't solve it.
Can someone help me please?
Thanks a lot guys!
2 Commenti
Dhanashree Mohite
il 8 Apr 2019
As per my understanding, Line no. 5 should contain 'condition_fs' instead of 'condition'.
it should be:
for condition_fs = 1:5
Hope you have 'samplingRate' defined. Else it will give error as:
Undefined function or variable 'samplingRate'
Risposte (1)
KSSV
il 8 Apr 2019
myPitches = [500, 1000, 1500, 2000, 2500];
condition_fs = [1 2 3 4 5];
howLong = .5;
presentedPitches = [];
for condition = 1:5 % five frequencies
for trial = 1:20 % presentation for each frequency
% Random presentation of sounds at different pitches
RandPitches = randperm(5,1);
pitch = myPitches(condition_fs(RandPitches));
presentedPitches(condition_fs, trial) = pitch; % save pitches
pause(1.5)
[beep] = MakeBeep(pitch, howLong, samplingRate);
end
end
Vedere anche
Categorie
Scopri di più su Multirate Signal Processing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!