运行GUI要求在GUIDE中打开.fig文件 [英] Running a GUI requires opening the .fig file in GUIDE

查看:316
本文介绍了运行GUI要求在GUIDE中打开.fig文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行我创建的MATLAB GUI.如果我使用GUIDE打开.fig文件,然后在其中按运行按钮,它将运行完美.

I am trying to run a MATLAB GUI I have created. If I open the .fig file using GUIDE and press the run button there, it runs perfectly.

但是,当我在MATLAB的当前文件夹"部分中双击.fig文件时,似乎找不到handles变量.每当使用handles时,这都会导致错误.

However, when I double-click the .fig file in the 'Current Folder' section of MATLAB, it seems to be unable to find the handles variable. This causes it to give an error whenever handles is used.

为什么会这样?是否有修复/解决方法?

Why does this happen? Is there a fix/workaround?

我正在使用MATLAB R2011,但我也在R2012上尝试过.该代码可以正常运行,并且可以很好地显示GUI,但是一旦遇到handles变量,就会出现以下错误:

I'm using MATLAB R2011, but I've tried it on R2012 as well. The code runs fine, and displays the GUI fine, but the moment it encounters the handles variable, it gives the following error:

尝试引用非结构数组的引用字段.

推荐答案

使用GUIDE创建GUI时,它应该同时创建.fig文件和.m文件.要运行它,您应该运行.m文件,而不是双击.fig文件.

When you create a GUI using GUIDE, it should create both a .fig file and a .m file. To run it, you should run the .m file, rather than double-clicking the .fig file.

.fig文件仅包含有关GUI布局的静态信息-文件中没有可初始化handles的可执行文件,依此类推.

The .fig file just contains static information about the layout of the GUI - there is nothing executable in it that would initialise handles and so on.

这篇关于运行GUI要求在GUIDE中打开.fig文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆