How can I process a '.mat' file??

If you download the program you will see there is a ButtonIcons.mat file which I think are the icons for the GUI buttons on the guitar tuner. How can I process this file ??

11 Comments

mat files are binary files which contain variables of any kind. Just drag+drop the file into the workspace window or enter 'load filename.mat' into the command window and the respective variables will be loaded.
Thanks for replying ! I meant how can I create my own .mat file or furthermore how can I sort of change whats inside an already existing .mat file :/
load
to load it into the workspace
save
to save it again. You have to use strings for variable names in saving unless you want to save your whole workspace, but the help explains that.
save(filename) will overwrite the data in the existing mat file by default. Use the '-append' tag to add data to an existing mat file without deleting the other data in there. If there's no file with this name, it will just be created (however, '-append' will throw an error then).
John Bitzios
John Bitzios on 28 Aug 2014
Edited: John Bitzios on 28 Aug 2014
I wrote at the command window "load ButtonIcons.mat" but it wont do anything....it just changes line (not showing error or anything btw), maybe it has to do something with the file path...I dont know...just saying
I am still not sure if you got my question right... on the specific program I linked on my question there are 3 files 1)GuitarTuner.m (which contains the program code) 2)GuitarTuner.fig (GUI) and 3)ButtonIcons.mat (pictures or shapes attached to gui buttons)
those pictures attached to those buttons how can I change them? Because its an external file and I dont know how to open it on matlab...thats actually my question :D
Well, that's what I said: Open the mat file via load or by drag-and-drop, then change the value of one of the variables and save the mat file again. E.g.
load('D:\MATLAB\fileexchange\GuitarTuner\ButtonIcons.mat')
PlayDisabled=PlayDisabled(:,:,[3,1,2]);
save('D:\MATLAB\fileexchange\GuitarTuner\ButtonIcons.mat')
GuitarTuner
makes the play button appear blue.
cool! Seems to work! Is there a list with those attributes?? How did the author create the play button in the first place??
Which attribute do you mean? The '-append'? That's described in the help of the function. I guess, the author has either drawn it in some other program (e.g. Paint)and saved it as bitmap. In Matlab it's possible, too, of course, just a bit more work.
Is it a lot of work or a piece of cake?? If its a lot of work then I dont want to spend my time on it...but if its easy then I would like a few more information on it...for example how can you change the colour with only this command??
PlayDisabled=PlayDisabled(:,:,[3,1,2]);
Not much work for such a small image, just not as handy as in Paint or similar programs (when I woke up in the morning, I didn't expect to call Paint a handy program today). Anyway, you can just read wiki or similar about RGB images. There will be better explanations along with illustrations than I could ever provide. If you want to know what this [3,1,2] was, just define a little vector a=1:5 and play around with it the same way (a([3,1,2]),a([1,3,5]), whatever). You'll quickly see what happens ;-)

Sign in to comment.

Answers (0)

Products

Asked:

on 28 Aug 2014

Commented:

on 28 Aug 2014

Community Treasure Hunt

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

Start Hunting!