MATLAB Answers

How can we convert struct file to txt file?

59 views (last 30 days)
furkan akhan
furkan akhan on 27 Feb 2021
Commented: dpb on 28 Feb 2021
We have a 5x1 struct file as you can see in the picture. IDs represent the names of the patients, so we have 5 patients. We want to save sounddata and flow data for each patient separately as txt file.

Accepted Answer

dpb on 27 Feb 2021
arrayfun(@(s) writematrix([s.S s.F],[s.ID '.txt']),structWheeze)
dpb on 28 Feb 2021
That's what arrayfun does ... did you try it and see what you got?
>> dir yk*.txt
yk103.txt yk104.txt
See??? There are two elements of the sample struct and two text files were created with the IDs in the array...
>> structWheeze.ID
ans =
ans =

Sign in to comment.

More Answers (0)


Community Treasure Hunt

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

Start Hunting!