EXTRACT TABLE FROM DATA

2 次查看(过去 30 天)
DavidL88
DavidL88 2020-10-16
评论: DavidL88 2020-10-16
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

采纳的回答

Jon
Jon 2020-10-16
编辑:Jon 2020-10-16
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 个评论
Jon
Jon 2020-10-16
Are you sure they have the same number of columns for every iteration? It seems surprising that there would be exactly 35 values satisfying your pvalue condition for every iteration.
I would step through with the debug tool and see how many rows and columns each one has at each stage. If you havent' used the debugging tools I would highly recommend them as a quick way to find out what is going on. Here's a link https://www.mathworks.com/help/matlab/matlab_prog/debugging-process-and-features.html
Also you can nicely format your code using the code button on the MATLAB answers interface
DavidL88
DavidL88 2020-10-16
I figured it out. You were right. I used the min function so only one vale was returned per iteration.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by