How to close a .mat file

조회 수: 8 (최근 30일)
Nathanael
Nathanael 2014년 1월 16일
답변: Li GMA 2019년 8월 14일
Hello!
When loading a "*.mat" file i simply use load('foo.mat'), how can i close this file after loading it?
Thank you
  댓글 수: 2
jacky chen
jacky chen 2014년 1월 16일
it's a good question ,you maybe can load the *.mat in a subprogram, then you can return the variable and know which variable is in the *.mat, then use clear to delete them .
Nathanael
Nathanael 2014년 1월 16일
Thank you! Is it possible to create a blank mat file? Without loading the varibles in the workspace with it?

댓글을 달려면 로그인하십시오.

답변 (2개)

Friedrich
Friedrich 2014년 1월 16일
The load command should do that automatically. Load open the file, reads the data and closes the file aftwards. So there is no need for your to close it.
  댓글 수: 2
jacky chen
jacky chen 2014년 1월 16일
he maybe just wants to delete the variable from load..
Walter Roberson
Walter Roberson 2014년 1월 16일
In that case use
struct_name = load('foo.mat');
and refer to struct_name.VARIABLENAME instead of VARIABLENAME . Then
clear struct_name
to get rid of them all.

댓글을 달려면 로그인하십시오.


Li GMA
Li GMA 2019년 8월 14일
Also there is a button in the top panel, "Clear Workspace".

카테고리

Help CenterFile Exchange에서 Workspace Variables and MAT Files에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by