MATLAB: How to pass the filename entered from the user to execute a command in command prompt

dos commadstructures

So what i need to do is input the filename from the user and then use this filename in the following way
data.file = input('Please enter the file name ');
status = dos('Extractdata data.file');
Here user will enter the filename which will be stored in 'data.file' and that filename has to go into the second line of code that i showed above. However if I write data.file it gives an error which is obvious. How to get around this? Any help is appreciated. Thanks.

Best Answer

You need to concatenate the character array you have captured to the other part of the command:
status = dos(['Extractdata ',data.file]);
I would recommend against using the variable name "data.file" to capture that info, because you are unnecessarily using a MATLAB struct. Maybe just call it "filename", or something similar, which will just be a simple character array.