Variabili del workspace e file MAT
Il workspace contiene variabili create dall'utente o importate in MATLAB da file di dati o da altri programmi. È possibile visualizzare e modificare i contenuti del workspace nel pannello Workspace o nella finestra di comando. Per maggiori informazioni, vedere Create and Edit Variables.
Le variabili del workspace non vengono conservate quando si esce da MATLAB. Per utilizzare i dati tra più sessioni, salvarli in un file compresso con estensione .mat
, chiamato file MAT. È possibile ripristinare i dati salvati caricando un file MAT in MATLAB. Per maggiori informazioni, vedere Salvataggio e caricamento delle variabili del workspace.
Strumenti
Workspace Panel | Interactively manage workspace contents |
Variables Editor | Interactively view, edit, and analyze workspace variables |
Import Tool | Import data from file |
Attività di Live Editor
Importazione dei dati | Import data from a file in the Live Editor (Da R2023a) |
Funzioni
load | Caricare le variabili dal file al workspace |
save | Salvare le variabili dal workspace a un file |
matfile | Access and change variables in MAT-file without loading file into memory |
disp | Visualizzare il valore della variabile |
formattedDisplayText | Capture display output as string (Da R2021a) |
who | List variables in workspace |
whos | List variables in workspace, with sizes and types |
clear | Remove items from workspace, freeing up system memory |
clearvars | Clear variables from memory |
Argomenti
- Create and Edit Variables
Create, edit, and copy variables in the MATLAB workspace using the Command Window, Workspace panel, and Variables editor.
- Salvataggio e caricamento delle variabili del workspace
Salvare alcune o tutte le variabili dell'attuale workspace e ricaricale in un secondo momento durante la sessione attuale di MATLAB o durante un'altra sessione.
- Modify Workspace and Variables Settings
Set settings for the Workspace panel and Variables editor.
- MAT-File Versions
There are several versions of MAT-files that each support an increasing set of features, starting with MAT-file Version 4.
- Compare and Merge MAT-files
View and merge changes between two MAT-files.
Risoluzione dei problemi
Unexpected Results When Loading Variables Within a Function
If you have a function that loads data from a MAT-file and find that MATLAB does not return the expected results, check whether any variables in the MAT-file share the same name as a MATLAB function.