- You have files (referred to as ‘subjects’ by you) named as ‘sub1’, ‘sub2’ , …, ‘sub44’.
- Each file has multiple columns (you have referred to them as ‘features’).
- You want to loop through the 44 files and extract certain features from each file.
How to read different features from multiple subjects?
조회 수: 2 (최근 30일)
이전 댓글 표시
I have 44 subjects with name sub1 to sub44. I want to extract various features from the matlab double format. Kindly guide me how to design the loop to execute the files so that I can extract the whole features by using a single loop. Thanking in advance !!
댓글 수: 0
답변 (1개)
Zinea
2024년 2월 22일
Based on my understanding of the question:
You can refer to the example code below where I have taken the case if you want to extract features corresponding to say, column 2 and column 4:
% Preallocate cell arrays to store the extracted features
feature2 = cell(44, 1);
feature4 = cell(44, 1);
% Loop through each file
for i = 1:44
% Construct the filename
filename = sprintf('sub%d', i);
% Load the data from the file
data = load(filename);
% Extract feature2 and feature4
feature2{i} = data(:, 2); % Extract the second column
feature4{i} = data(:, 4); % Extract the fourth column
end
After the loop, the cell arrays feature2 and feature4 will contain the extracted features from all the files.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Large Files and Big Data에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!