I have 33 csv files from different locations and I would like retrieve each file, get the content and dump it in a cell. This cell should contain information (all scalar values) from all the individual files. Each individual file has 3 rows and 16 columns. I would like to create a 99 x 16 cell (called P). 99 rows would be from 3 rows per each of the 33 files. The 16 columns are 16 columns from each file.
So far I have created a loop to retrieve each file:
P=cell(length(Q)*3,16); % Q contain the name of the files
for k=1:length(Q)
dire_FIX = '/Data3/ledata/FHSWD/Scan_data/';
data_path=[dire_FIX Q{k}];
data = spm_select('FPList', fullfile(data_path), sprintf('^%s.*\\.csv$', Q{k})); % get each file
Values = load (data)
Here is where I got stuck. Values should be a 3x16 cell. How do I put each Values into P without overwriting the previous Values.
Thank you!
Initialize P to an empty matrix:
P =[];
Put this at the end of your for-loop:
P(:, end+1) = Values{:, 1};
P(:, end+1) = Values{:, 2};
P(:, end+1) = Values{:, 3};
That should do it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.