在matlab中从uimenu打开文件
Opening files from uimenu in matlab
我还在做我的项目,我又碰壁了。
在这种情况下,我试图从 uimenu 打开一个 .pdf 文件,我搜索了所有函数,我想我找到了正确的:
x = 'D:\MATLAB\Author.pdf';
y = 'D:\MATLAB\Bibliography.pdf';
f=uimenu('Label','ProjectData');
uimenu(f,'Label','Author','Callback','fopen(x)');
uimenu(f,'Label','Bibliography','Callback','fopen(y)');
uimenu(f,'Label','Close','Callback','close',...
'Separator','on','Accelerator','Q');
但问题是,当我点击作者或参考书目时,没有任何反应,没有错误,什么也没有。
命令 window 中唯一出现的是:
答案=
-1
.pdf 文件与其余 .m 文件位于同一文件夹中。
请帮忙,谢谢!
那是因为 MATLAB 无法打开您的文件。
来自 fopen
文档(可用 here)(粗体来自我):
fileID = fopen(filename) opens the file, filename, for binary read
access, and returns an integer file identifier equal to or greater
than 3. MATLAB® reserves file identifiers 0, 1, and 2 for standard
input, standard output (the screen), and standard error, respectively.
If fopen cannot open the file, then fileID is -1.
所以 MATLAB 给出的文件 ID 为 -1。如果您希望 MATLAB 打开适用于您的 pdf 文件的应用程序(即 Adobe Acrobat),您可以使用 open.
如果你真的想在 MATLAB 中将 pdf 作为图像打开,File Exchange 上可能有一些功能。
希望对您有所帮助!
我还在做我的项目,我又碰壁了。
在这种情况下,我试图从 uimenu 打开一个 .pdf 文件,我搜索了所有函数,我想我找到了正确的:
x = 'D:\MATLAB\Author.pdf';
y = 'D:\MATLAB\Bibliography.pdf';
f=uimenu('Label','ProjectData');
uimenu(f,'Label','Author','Callback','fopen(x)');
uimenu(f,'Label','Bibliography','Callback','fopen(y)');
uimenu(f,'Label','Close','Callback','close',...
'Separator','on','Accelerator','Q');
但问题是,当我点击作者或参考书目时,没有任何反应,没有错误,什么也没有。 命令 window 中唯一出现的是:
答案=
-1
.pdf 文件与其余 .m 文件位于同一文件夹中。
请帮忙,谢谢!
那是因为 MATLAB 无法打开您的文件。
来自 fopen
文档(可用 here)(粗体来自我):
fileID = fopen(filename) opens the file, filename, for binary read access, and returns an integer file identifier equal to or greater than 3. MATLAB® reserves file identifiers 0, 1, and 2 for standard input, standard output (the screen), and standard error, respectively.
If fopen cannot open the file, then fileID is -1.
所以 MATLAB 给出的文件 ID 为 -1。如果您希望 MATLAB 打开适用于您的 pdf 文件的应用程序(即 Adobe Acrobat),您可以使用 open.
如果你真的想在 MATLAB 中将 pdf 作为图像打开,File Exchange 上可能有一些功能。
希望对您有所帮助!