MATLAB Answers

EXTRACT TABLE FROM DATA

5 views (last 30 days)
DavidL88
DavidL88 on 16 Oct 2020
Commented: DavidL88 on 16 Oct 2020
Hi
I'm using the below script to extract some data to place in a table. When I run this script I get this error message. A1, A2 and A3 are all returned correctly as 1x35 double. T1, T2 and T3 are all incorrectly returned as 1x3 double. When I remove all T1, T2 and T3 variables from this script, A1-3 return as empty, just '[]'. Can anyone tell me why this is the case and why I get the error message belwo when I include the T1-3 variables in the script?
Error using vertcat
Dimensions of arrays being concatenated are not consistent.
Error in working_file_2 (line 29)
T1 = [T1; A1];
% Process: Select files using search query
sFiles = bst_process('CallProcess', 'process_select_search', [], [], ...
'search', '(([path CONTAINS "ERP_perm_ROI"] AND [name CONTAINS "Perm t-test equal"]))');
T1 = [];
T2 = [];
T3 = [];
for iFile = 1:length(sFiles)
DataMat = in_bst_data(sFiles(iFile).FileName);
analysis = DataMat.Comment
tvalue = DataMat.tmap
pvalue = DataMat.pmap
time = DataMat.Time
col = find(pvalue(1,:)<=0.05);
A1 = pvalue(:,col);
A2 = tvalue(:,col);
A3 = time(:,col);
T1 = [T1; A1];
T2 = [T2; A2];
T3 = [T3; A3];
end

Accepted Answer

Jon
Jon on 16 Oct 2020
Edited: Jon on 16 Oct 2020
You may have a different number of columns each time through the loop. You can't just stack them on top of each other if they don't have the same number of columns each time.
Note that the columns that you select are based on the criteria
col = find(pvalue(1,:)<=0.05);
The result may be different columns, and in particular a different number of columns each time
  3 Comments
DavidL88
DavidL88 on 16 Oct 2020
I figured it out. You were right. I used the min function so only one vale was returned per iteration.

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!