Load multiple matlab data files and convert them to text
Show older comments
Hi!
I have multiple matlab data files with different names (with ECG data from multiple patients) and I want to load them all and convert them to text.
Also, the data is in structure form so I have to do the following for each file:
signal = load('FileName')
data = [signal.val];
writematrix(data,'FileName.txt','Delimiter',',');
How can I do it all at the same time? Thank you a lot in advance :)
Accepted Answer
More Answers (1)
Sulaymon Eshkabilov
on 4 Jul 2021
If you are talking about series of files (e.g: P1.txt, P2.txt, ...) to load and convert their contents, then this might be an option:
for ii = 1:numel(Files)
FName = strcat('P', num2str(ii), '.txt');
signal = load(FName)
data = [signal.val];
writematrix(data,'FileName.txt','Delimiter',',', 'WriteMode','append');
end
1 Comment
Ana Gabriela Guedes
on 4 Jul 2021
Categories
Find more on Convert Image Type in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!