How to make the output of a command into the variable for data

2 views (last 30 days)
Hello,
I am using fileparts to extract the file names and use that as the variable for the data in the struct below. How do I make output "Patient001" as the variable name for the struct that is currently called "PatientData"? without having to manually doing it. Eventually I want to be able to loop through hundreds of patient files.
Thank you
file = "Patient001.pdf";
[pathstr,PatientName,ext] = fileparts(file)
PatientName =
"Patient001"
PatientData = {1, 2, 3, 4}

Accepted Answer

Cris LaPierre
Cris LaPierre on 12 Jan 2022
Edited: Cris LaPierre on 12 Jan 2022
You might also be interested in the RenameField function, available on the File Exchange (created by a community member).

More Answers (0)

Categories

Find more on Structures in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!