Open File From A Full File Path & Extension

65 views (last 30 days)
Hello all
I have to be honest, what seems to be a very simple task is proving to be a huge nightmare to preform in Matlab.
I want to open a file from its full file path - but really struggling.
I have a variable that contains the full file path of a file that i want to open:-
T = C:\Users\mal\Documents\Matlab\Profile.csv
I simply want to open it - how can i achieve this?
The file is not always a .csv it can be xls or txt etc i simply want to open it and let windows decide which program to open it in.
Cany ideas?
Thank you.

Accepted Answer

Walter Roberson
Walter Roberson on 12 May 2019
T = 'C:\Users\mal\Documents\Matlab\Profile.csv';
winopen(T)
Note that this is specifically "let windows decide which program to open it in", not "let MATLAB decide which program or function to open it in". So for example for the CSV file, Windows would typically start up Excel and open the file in that, in a program disconnected from MATLAB, whereas MATLAB would typically use importdata() in order to read the file.
If you want MATLAB to decide how to open the file, then use open(T) instead of winopen(T)

More Answers (1)

Mohammad Maliq
Mohammad Maliq on 12 May 2019
Walter
Thank you for coming to the rescue again.
:)

Community Treasure Hunt

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

Start Hunting!

Translated by