Error using concatenate when trying to compile individual data (trying to make a histogram)
    3 ビュー (過去 30 日間)
  
       古いコメントを表示
    
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 件のコメント
回答 (2 件)
  Star Strider
      
      
 2014 年 11 月 24 日
        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 件のコメント
  Star Strider
      
      
 2014 年 11 月 24 日
				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?
参考
カテゴリ
				Help Center および File Exchange で Data Distribution Plots についてさらに検索
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
