Saving and opening Matlab file

19 vues (au cours des 30 derniers jours)
Jonas Grov Andersen
Jonas Grov Andersen le 12 Avr 2020
Modifié(e) : per isakson le 12 Avr 2020
Hi. I'm new to matlab. I was trying out how to plot and wanted to save the file for later. I named it 2D_Plot_Example.mat and saved it to a folder on my desktop.
Later i tried opening the file again in editor and everything i wrote is there. Except the plot dosen't show up and the colours isn't there.
(Example: Hold (on), Hold (off), ('r--'), (':'), and so on.
It's like everything is just text and not a code.
Do anyone know what i did wrong? Thanks! :)
  4 commentaires
Jonas Grov Andersen
Jonas Grov Andersen le 12 Avr 2020
Like this?
Jonas Grov Andersen
Jonas Grov Andersen le 12 Avr 2020
Maybe i should save them as .m instead of .mat?

Connectez-vous pour commenter.

Réponse acceptée

per isakson
per isakson le 12 Avr 2020
Modifié(e) : per isakson le 12 Avr 2020
"Except the plot dosen't show" Matlab doesn't recognise it as Matlab code.
The extension, .mat, indicates data. See Save and Load Workspace Variables
Ordinary Matlab m-code is stored in files with the extension, .m, (I didn't find a good reference.)
2D_Plot_Example is not a legal name for a file with m-code; first character shall be a letter (English) or underscore(?)
Conclusion: Save the code under the name TwoD_Plot_Example.m
  1 commentaire
Jonas Grov Andersen
Jonas Grov Andersen le 12 Avr 2020
Thanks! I think that did the trick! :D

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Environment and Settings dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by