Data not indexing properly?
Afficher commentaires plus anciens
Hi there,
I am compiling group data and plotting it with a best fit line, but am having issues with the way some of the output is indexing. For instance, I pull in the group data in a loop and concatenate it so I have all my data in one place. Then, I create an index for the values greater than zero and try to index into that later to make a new variable for best fit line plotting. Everything works until I do the last step, where it just seems to index into the 1st set of data I imported.
for isubj = 1:length(SUBJECTS)
if isubj == 1
qthres = xlsread(xlsfile, 1,'J3:J16');
peakamp = xlsread(xlsfile, 1, 'L3:L16');
scalae = xlsread(xlsfile, 1, 'C3:C16'); % can only use elecs 2-15 here because of qthres!
[STi, STj, ST] = (find(scalae == 1 & peakamp > 0));
[SMi, SMj,SM] = (find(scalae == 2 & peakamp > 0));
[SVi, SVj,SV] = (find(scalae == 3 & peakamp > 0));
[peakampi, peakampj] = find(peakamp > 0);
all the way to 8...
else isubj = 8
qthres = xlsread(xlsfile, 8,'J3:J16');
peakamp = xlsread(xlsfile, 8, 'L3:L16');
scalae = xlsread(xlsfile, 8, 'C3:C16');
[STi, STj, ST] = (find(scalae == 1 & peakamp > 0));
[SMi, SMj,SM] = (find(scalae == 2 & peakamp > 0));
[SVi, SVj,SV] = (find(scalae == 3 & peakamp > 0));
[peakampi, peakampj] = find(peakamp > 0);
end
....plot data which works fine...
if ~isrow(peakamp(peakampi))
peakamp(peakampi) = (peakamp(peakampi))';
end
allpeakamp = cat(2, allpeakamp, peakamp);
allthres = cat(2, allthres, qthres);
allscalae = cat(2, allscalae, scalae);
[findampi, findampj] = find(allpeakamp > 0);
[findthresi, findthresj] = find(allthres > 0);
...and end loop.
Both inside and outside the loop the above variables allpeakamp and findampi (for instance) look correct. However, when I try to do allpeakamp(findampi) so I can get values only above zero, it only indexes into subject 1's amplitudes, when it should be looking as a whole. I know something is wonky with how I"m doing it, but I can't put my finger on it. Essentially I need to compile the group amplitudes, find what's above zero, and use that to plot a best fit line against threshold...and the same issue is occurring with threshold as well.
Sorry this is so long. Thanks!
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Performance and Memory dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!