在MATLAB中clear(Filename)有什么作用?

|
files=dir(\'*.cpp\');
for i=1:length(files)
    Filename=files(i).name;
    clear(Filename); 
    ......
end
有人可以解释clear(Filename)做什么吗?我认为它不会删除变量Filename,因为我仍然在工作场所看到该变量。     
已邀请:
        
clear(str)
将清除名称由
str
中的字符串指定的变量。从文档中:   “ 3”是语法的函数形式。此形式用于存储在字符串中的变量名和函数名。 因此,在您的情况下,它将清除名称为
files(i).name
中的字符串的变量。 例:
>> a=1:10;
>> str=\'a\';

%#check what variables are in the workspace
>> whos
  Name      Size            Bytes  Class     Attributes

  a         1x10               80  double              
  str       1x1                 2  char                

>> clear(str)

%#check again
>> whos
  Name      Size            Bytes  Class    Attributes

  str       1x1                 2  char        
    
        它正在清除变量files(i).name,其中files(i).name被评估为filname的名称 假设您有一个名为\'test.cpp \'的变量和一个名为\'test.cpp \'的文件名 这将从工作空间中清除变量\'test.cpp \'     

要回复问题请先登录注册