How do you open .MAT files with variables?
December 10, 2009 1:13 PM   Subscribe

I need help opening Matlab workspaces

I'm on a computer running Windows XP. Until today, Matlab workspaces (.MAT) opened just fine, but then out of nowhere it reverted back to thinking they were some sort of file associated with Microsoft Access. I went into Windows Explorer > Tools > Folder Options > MAT > Advanced > Edit and changed it back to opening with the Matlab.exe file, but now the workspace variables don't appear. Googling hasn't helped much.

Does anybody know what the nuance is to opening these files with the workspace variables? Perhaps if someone could just copy the settings they have to here that would be enough. Thanks.
posted by cali59 to Computers & Internet (6 answers total)
 
Have you read this guidance?
posted by Mike1024 at 1:30 PM on December 10, 2009


Response by poster: Thank you. I hadn't read that particular page, just some similar ones. I followed the instructions (except for the command prompt utility which isn't working). Still it's not working. The MAT file opens but with nothing in the workspace.
posted by cali59 at 2:40 PM on December 10, 2009


If you change the MAT file to a .m file, you should be able to just declare all of the variables explicitly.

If, in a .m file you say
x = 100;
y = 200;
z = y-x;

then x, y, and z will all be in your workspace. It is more of a workaround but it will work-around . . .

Are you double-clicking the files from Windows or actually "running" them as commands inside of MATLAB? That might change the behavior. Make sure the the file is set up in your "path" (I am sorry if I am stating the obvious, it is hard to tell how much experience you have with the software.

Also, you might try "Open with..." in a right click context menu off the file, maybe that will use some other Windows logic to process?

Good luck, see if any of that improves your situation.
posted by milqman at 3:20 PM on December 10, 2009


Best answer: I've reproduced this fault on my home copy of Matlab 6.5

Unfortunately I don't know what the original settings were (my .mat files were associated with access too) but here's a workaround which works for me:

Go to 'folder options' and delete the entry for the MAT file type. Create a new entry for the same file type, click the 'advanced' button, and create a new action. Name the new action Open, and set the application to:
"C:\Program Files\Matlab65\bin\win32\matlab.exe" -r "load '%1'"
where the first bit is the path to matlab.exe on your system. (You might want to assign an icon to your new file type as well.)

Anyway, what that setting should mean is that, when you double-click a .mat file, matlab should be started with the parameter -r "load '%1'" where %1 is the name of the file you double-clicked, and where the parameter -r means "load matlab then run this command". Result: Double-clicking a .mat file loads matlab and runs a command to open the file you double-clicked.

Tomorrow when I'm in work I'll see if my copy of matlab there still has its original file associations intact, and if it does I'll get a copy of them for you.
posted by Mike1024 at 4:15 PM on December 10, 2009


Response by poster: Perfect, thank you.
posted by cali59 at 5:12 PM on December 10, 2009


The Matlab help utility also provides a way to restore file associations. From the help browser, search for "Run utility to associate MATLAB with MAT-files" (including the quotes). Clicking the link that matches this text will restore the file association.
posted by yarmond at 5:18 PM on December 10, 2009


« Older DIY Glasses   |   How to secure folder with chmod. Newer »
This thread is closed to new comments.