Add lines to a struct
7 views (last 30 days)
Show older comments
I have a struct where one of the columns is the PatientID that appears like this 'P00000001' and I want to add more patients with a diferent PacientID but with the same structer ('P00000001' - a string with P and 8 numbers) how do I do?
2 Comments
Answers (1)
Adam Danz
on 27 Dec 2021
Edited: Adam Danz
on 27 Dec 2021
s = struct();
s.(sprintf('P%08.0f',1)) = 'Baetriz';
s.(sprintf('P%08.0f',2)) = 'Adam';
s.(sprintf('P%08.0f',3)) = 'Matlab'
Or if you're refering to tables,
T = table();
T.(sprintf('P%08.0f',1)) = 'Baetriz';
T.(sprintf('P%08.0f',2)) = 'Adam';
T.(sprintf('P%08.0f',3)) = 'Matlab'
2 Comments
See Also
Categories
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!