【发布时间】:2011-04-01 17:45:57
【问题描述】:
我想知道是否有人可以对 Matlab fopen 命令的以下问题有所了解:
>> [stat myjob] = unix('echo $PBS_NODEFILE'); % gets PBS file name with allocated nodes
>> myjob
myjob =
/opt/torque/aux//66058.crunch.local
>> fid = fopen('/opt/torque/aux//66058.crunch.local')
fid =
3
>> fgetl(fid)
ans =
compute-9-2
>> fclose(fid);
我需要节点的名称来控制脚本中的一些后续决定。如果我从事交互式 PBS 工作,上述方法可以工作,但在大多数情况下,尽管我需要在没有干预的情况下启动这些工作。当我尝试通过存储的文件名执行此操作时:
>> fid = fopen(myjob) % returns invalid
fid =
-1
>> fgetl(fid)
??? Error using ==> fgetl at 44
Invalid file identifier. Use fopen to generate a valid file identifier.
为什么,当我直接输入存储在 myjob 中的值时,我会得到一个有效的标识符,但是当我输入 myjob 时它会失败?
谢谢, 安德鲁
【问题讨论】:
-
如果你使用
[fid, message] = fopen(myjob)会得到什么错误信息? -
变量
myjob是char类吗?