How to save one of the variable in workspace in .mat format?
92 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I want to save one of the variable(50*110 size) from matlab workspace in .mat file.I need to send this file to my professor as attachment so that he can use imtool on that variable to get a image. I tried with save command, but I ended up with shortcut file which did not open in my own computer and I also couldn't upload that one as attachment. Any help will be highly appreciated.
0 Kommentare
Antworten (4)
Thomas
am 3 Jul. 2012
a=rand(50,110); % create random data
save('output.mat','a') % save variable in the output.mat file
check to see if the output.mat is created and load it again
clear variables % clear variables from workspace
load('output.mat')
Now variable a should be back in workspace..
0 Kommentare
Image Analyst
am 3 Jul. 2012
Bearbeitet: Image Analyst
am 3 Jul. 2012
I know you know how to attach files to an email, but that's not your problem. The problem is that when you save a .mat file, Windows thinks this is a "Microsoft Office Access Table Shortcut" and it doesn't show the file with the extension in Windows Explorer even though you told it to show all extensions (through folder options) and not to hide extensions. And the file shows up as a shortcut, as you said.
The Mathworks has a tech note on this:
unfortunately it only applies to Windows XP. Which version of Windows do you have?
To fix it for Windows 7,
- Click the Windows flag button,
- Type regedit in the Search Programs and Files" edit field
- Browse to field HKEY_CLASSES_ROOT\.mat\OpenWithProgids
- Note the name of the MATLAB KEY, for example MATLAB.mat.7.14.0
- Browse to field HKEY_CLASSES_ROOT\.mat\OpenWithProgids
- Double click the (Default) name.
- Type in the MATLAB name, for example MATLAB.mat.7.14.0, into the Value data field, and click OK
- Exit out of regedit
- Restart your computer, (unfortunately this is necessary to re-read the registry as restarting Windows Explorer is not enough).
Nonetheless, even if you don't fix how it's displayed, you can still send the file as an attachment to your email.
4 Kommentare
Tom
am 3 Jul. 2012
would it be worth, for now, writing the variable to a txt or xls file, and having your professor import it?
Image Analyst
am 3 Jul. 2012
That's not needed. Like I said, it's still the same file with the same contents regardless of what it looks like in Windows Explorer or what default program Windows XP decides to open it with when you double click on it. He can just send without any issues.
Bibek
am 3 Jul. 2012
2 Kommentare
Tom
am 3 Jul. 2012
what's stopping you from sending the saved .mat file with the one variable stored in it?
Thomas
am 3 Jul. 2012
that is exactly what this does.. I just showed the load command to confirm that the variable a was stored in the output.mat file.. You can attach the output.mat file via email, but your professor need matlab to open the output.mat file.
He needs to run the
load('output.mat')
in his MATLAB after he receives the file to work on it..
Siehe auch
Kategorien
Mehr zu Data Import and Export finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!