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

 Akzeptierte Antwort

Jon
Jon am 16 Okt. 2020
Bearbeitet: Jon am 16 Okt. 2020

0 Stimmen

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 Kommentare

DavidL88
DavidL88 am 16 Okt. 2020
I'm not sure how? A1, A2 and A3 all return 1x35 double so seems to be the exact same number of columns. The code is also returning the correct data for these variables (A1, A2 and A3).
Jon
Jon am 16 Okt. 2020
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 am 16 Okt. 2020
I figured it out. You were right. I used the min function so only one vale was returned per iteration.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Tags

Gefragt:

am 16 Okt. 2020

Kommentiert:

am 16 Okt. 2020

Community Treasure Hunt

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

Start Hunting!

Translated by