Reputation: 25
How do I convert a .m
file to a .mat
file that can be use as an argument for a function on MATLAB? The .m
file is a matrix.
Upvotes: 0
Views: 2766
Reputation: 381
I'm not sure what you mean by "The .m
file is a matrix" but if it's already in the Matlab data format, can't you just change the extension directly?
If it's in any other format that you are able to import into the workspace, you can import it then use
save mydata.mat
to save it to a .mat file. Note that this will save all your workspace variables to the .mat file. To save only a specific variable, you can use the full form
save('mydata.mat', myVar)
You can also specify a relative or absolute path for the output file.
Upvotes: 3