Importing 3D matrix (.mat file format) via 'select file' if filename is unknown

2 views (last 30 days)
Hey everyone,
probably a very basic question but I just can't find the answer. I have a script which contains a variable, an array in the format 400x400x2000 double (so basically a 3D matrix). I then save this variable as a .mat file on my PC.
Opening a new script, I can then click on 'Import Data' in the Home window, search for the file on my PC and it opens this 3D matrix and I have a variable in the same format 400x400x2000 double.
So, what I need: instead of clicking on 'Import Data' in the home window, I want to implement this in my script, so that I press 'Run' and the first thing is a window popping up where I can select the file and import it.
I thought this would be easy, but all the commands like 'load', imply that you have a filename ready, which I don't as it varies all the time. So how can I simply load that 3D matrix by searching for it???
I did use this command: [DataFilename, DataFilePathName] = uigetfile( '*.mat*')
But this won't give me my matrix as a 3D matrix in the double format. It will return 'abc' variables of DataFilename and DataPathName...I guess these two contain my 3D matrix somehow but I don't know how to get it out of there either....
It would be easier if I could just import the 3D matrix similar to the way when you do it manually via 'Import Data'...
Any suggestions?

Answers (0)

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!