Error using concatenate when trying to compile individual data (trying to make a histogram)
6 views (last 30 days)
Show older comments
Hi, I'm trying to compile data from 8 subjects into 3 vectors organized by scalae (as relates to a behavioral threshold). I am able to do that, but once I try to concatenate them so as to compile the data, I keep getting this error:
Error using cat Dimensions of matrices being concatenated are not consistent.
Error in histogram_scalae (line 37) allST = cat(2, allST, thresST);
I think it is because not all subjects have electrodes in all scalae (so some will have from 2 and 3, some from 1 and 2) and it doesn't know what to fill it with when this happens. I can't seem to work around it.
Here is my code below:
SUBJECTS = [22 29 38 40 41 42 43 44];
xlsfile = 'C:\Users\Lindsay\Desktop\CTinfo_Oct_2014.xlsx'; %%change to school path
%create empty vectors to be filled in the loop
allthres = [];
allST = [];
allSV = [];
allSM = [];
thresind = [];
%%cycle through all subjects, importing data from Excel
for iSubj = 1:length(SUBJECTS)
%%import relevant data from Excel
qthres = xlsread(xlsfile, iSubj,'J3:J16');
scalae = xlsread(xlsfile, iSubj, 'C3:C16');
%finds scalae
[STi, STj, ST] = (find(scalae == 1 & qthres > 0));
[SMi, SMj,SM] = (find(scalae == 2 & qthres > 0));
[SVi, SVj,SV] = (find(scalae == 3 & qthres > 0));
thresST = qthres(STi);
thresSM = qthres(SMi);
thresSV = qthres(SVi);
%store scalae info for each subject
allST = cat(2, allST, thresST);
allSM = cat(2, allSM, thresSM);
allSV = cat(2, allSV, thresSV);
end
%%plot histogram%%
figure(1);
hist(thresST);
hold on;
hist(thresSM);
hist(thresSV);
THANKS!
0 Comments
Answers (2)
Star Strider
on 24 Nov 2014
I am not certain I understand what you’re doing or what the significance of the scalae electrode positions are in your data. Creating empty vectors might not be your best option. Instead, preallocating matrices so that all are equal size might be better. It could also solve your concatenation problem.
2 Comments
Star Strider
on 24 Nov 2014
No worries. I’ll continue my comments here.
I’m having problems understanding your code. If you’re getting electrode position on y rather than your scalae value, how do your electrode positions relate to your scalae values? (Your ‘ST’, ‘SM’, and ‘SV’ variables seem to be separated as ‘scalae’.) What is supposed to be on the x-axis?
See Also
Categories
Find more on Data Distribution Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!