Execute a function call in GUIDE

1 次查看(过去 30 天)
Amanda
Amanda 2012-9-2
I have this independent function which runs optimal in the command line:
function datacollect()
filename = uigetfile('*.txt')
[col] = importdata(fileName)
long = columns(:,1)
lat = columns(:,2)
handles.long = long;
handles.lat = lat;
But when I make a function call inside GUIDE:
datacollect()
I get an error:
??? Reference to non-existent field 'output'.
Thanks,
Amanda

回答(1 个)

Image Analyst
Image Analyst 2012-9-2
Copy and paste all the red text, don't selectively copy just what you think might be needed. By the way, since datacollect() is an independent function you wrote, it doesn't automatically have access to the handles structure of GUIDE. So you're creating your own handles structure. If you want it to have GUIDE's handle structure, you must pass it in via the arg list, or use other methods described in the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.28s.29.3F
  2 个评论
Amanda
Amanda 2012-9-2
编辑:Amanda 2012-9-2
I'm confused. I just want to call a function inside GUIDE.
Nice article though. Just need a few other examples...
Image Analyst
Image Analyst 2012-9-2
OK, you say "??? Reference to non-existent field 'output'" yet the code you posted didn't even refer to a variable or a field of a structure called output. So where did it get output from? I figure it's because you didn't paste all of your code and error message. In fact I KNOW you didn't paste all of your error message because error messages have a lot more information than you shared, such as line numbers. I'm afraid you left out all the crucial information that would allow us to solve your problem for you. That's why I asked you to copy and paste all the red error test that appears in the command window.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by