EXTRACT TABLE FROM DATA

1 回表示 (過去 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 Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by