Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
String problem

Subject: String problem

From: Rainaire

Date: 1 Apr, 2013 18:29:10

Message: 1 of 8

Hey im trying to make a game but my program keeps messing with me. Im using GUI and I have a bunch of figures opening each other. The problem is that one of my figures does not work properly and it keeps saying this:Attempt to reference field of non-structure array. Error in nairvnaircom>Chakra_Callback (line 528) set(handles.text5,'String',a); Error in gui_mainfcn (line 96) feval(varargin{:}); Error in nairvnaircom (line 42) gui_mainfcn(gui_State, varargin{:}); Error in @(hObject,eventdata)nairvnaircom('Chakra_Callback',hObject,eventdata,guidata(hObject)) Error while evaluating uicontrol Callback ; This only happens when I open up this fig from another figure. Im trying to make my text box say something every time i press a button. I just need it to work and to let the rest of my code work as well.

Subject: String problem

From: Steven_Lord

Date: 2 Apr, 2013 14:52:02

Message: 2 of 8



"Rainaire " <rhansford7@gmail.com> wrote in message
news:kjcjlm$5gm$1@newscl01ah.mathworks.com...
> Hey im trying to make a game but my program keeps messing with me. Im
> using GUI and I have a bunch of figures opening each other. The problem
> is that one of my figures does not work properly and it keeps saying
> this:Attempt to reference field of non-structure array. Error in
> nairvnaircom>Chakra_Callback (line 528) set(handles.text5,'String',a);
> Error in gui_mainfcn (line 96) feval(varargin{:}); Error in
> nairvnaircom (line 42) gui_mainfcn(gui_State, varargin{:}); Error in
> @(hObject,eventdata)nairvnaircom('Chakra_Callback',hObject,eventdata,guidata(hObject))
> Error while evaluating uicontrol Callback ; This only happens when I open
> up this fig from another figure. Im trying to make my text box say
> something every time i press a button. I just need it to work and to let
> the rest of my code work as well.

To open a GUI generated by GUIDE, you _MUST_ open it by running the function
file associated with the GUI. Opening it by opening the figure window
through the .fig file directly bypasses the initialization instructions in
the function file and the GUI will not work.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: String problem

From: Rainaire

Date: 3 Apr, 2013 17:37:06

Message: 3 of 8

"Steven_Lord" <slord@mathworks.com> wrote in message <kjerai$35h$1@newscl01ah.mathworks.com>...
>
>
> "Rainaire " <rhansford7@gmail.com> wrote in message
> news:kjcjlm$5gm$1@newscl01ah.mathworks.com...
> > Hey im trying to make a game but my program keeps messing with me. Im
> > using GUI and I have a bunch of figures opening each other. The problem
> > is that one of my figures does not work properly and it keeps saying
> > this:Attempt to reference field of non-structure array. Error in
> > nairvnaircom>Chakra_Callback (line 528) set(handles.text5,'String',a);
> > Error in gui_mainfcn (line 96) feval(varargin{:}); Error in
> > nairvnaircom (line 42) gui_mainfcn(gui_State, varargin{:}); Error in
> > @(hObject,eventdata)nairvnaircom('Chakra_Callback',hObject,eventdata,guidata(hObject))
> > Error while evaluating uicontrol Callback ; This only happens when I open
> > up this fig from another figure. Im trying to make my text box say
> > something every time i press a button. I just need it to work and to let
> > the rest of my code work as well.
>
> To open a GUI generated by GUIDE, you _MUST_ open it by running the function
> file associated with the GUI. Opening it by opening the figure window
> through the .fig file directly bypasses the initialization instructions in
> the function file and the GUI will not work.
>
> --
> Steve Lord
> slord@mathworks.com
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com

Subject: String problem

From: Rainaire

Date: 3 Apr, 2013 17:42:05

Message: 4 of 8

"Rainaire" wrote in message <kjhpc2$eck$1@newscl01ah.mathworks.com>...
> "Steven_Lord" <slord@mathworks.com> wrote in message <kjerai$35h$1@newscl01ah.mathworks.com>...
> >
> >
> > "Rainaire " <rhansford7@gmail.com> wrote in message
> > news:kjcjlm$5gm$1@newscl01ah.mathworks.com...
> > > Hey im trying to make a game but my program keeps messing with me. Im
> > > using GUI and I have a bunch of figures opening each other. The problem
> > > is that one of my figures does not work properly and it keeps saying
> > > this:Attempt to reference field of non-structure array. Error in
> > > nairvnaircom>Chakra_Callback (line 528) set(handles.text5,'String',a);
> > > Error in gui_mainfcn (line 96) feval(varargin{:}); Error in
> > > nairvnaircom (line 42) gui_mainfcn(gui_State, varargin{:}); Error in
> > > @(hObject,eventdata)nairvnaircom('Chakra_Callback',hObject,eventdata,guidata(hObject))
> > > Error while evaluating uicontrol Callback ; This only happens when I open
> > > up this fig from another figure. Im trying to make my text box say
> > > something every time i press a button. I just need it to work and to let
> > > the rest of my code work as well.
> >
> > To open a GUI generated by GUIDE, you _MUST_ open it by running the function
> > file associated with the GUI. Opening it by opening the figure window
> > through the .fig file directly bypasses the initialization instructions in
> > the function file and the GUI will not work.
> >
> > --
> > Steve Lord
> > slord@mathworks.com
> > To contact Technical Support use the Contact Us link on
> > http://www.mathworks.com

Ok so how do I do that? How do open the code for the figure and the figure also.

Subject: String problem

From: Rainaire

Date: 3 Apr, 2013 17:45:06

Message: 5 of 8

"Rainaire" wrote in message <kjhpc2$eck$1@newscl01ah.mathworks.com>...
> "Steven_Lord" <slord@mathworks.com> wrote in message <kjerai$35h$1@newscl01ah.mathworks.com>...
> >
> >
> > "Rainaire " <rhansford7@gmail.com> wrote in message
> > news:kjcjlm$5gm$1@newscl01ah.mathworks.com...
> > > Hey im trying to make a game but my program keeps messing with me. Im
> > > using GUI and I have a bunch of figures opening each other. The problem
> > > is that one of my figures does not work properly and it keeps saying
> > > this:Attempt to reference field of non-structure array. Error in
> > > nairvnaircom>Chakra_Callback (line 528) set(handles.text5,'String',a);
> > > Error in gui_mainfcn (line 96) feval(varargin{:}); Error in
> > > nairvnaircom (line 42) gui_mainfcn(gui_State, varargin{:}); Error in
> > > @(hObject,eventdata)nairvnaircom('Chakra_Callback',hObject,eventdata,guidata(hObject))
> > > Error while evaluating uicontrol Callback ; This only happens when I open
> > > up this fig from another figure. Im trying to make my text box say
> > > something every time i press a button. I just need it to work and to let
> > > the rest of my code work as well.
> >
> > To open a GUI generated by GUIDE, you _MUST_ open it by running the function
> > file associated with the GUI. Opening it by opening the figure window
> > through the .fig file directly bypasses the initialization instructions in
> > the function file and the GUI will not work.
> >
> > --
> > Steve Lord
> > slord@mathworks.com
> > To contact Technical Support use the Contact Us link on
> > http://www.mathworks.com

SO how do I do that?

Subject: String problem

From: Steven_Lord

Date: 3 Apr, 2013 18:40:09

Message: 6 of 8



"Rainaire " <rhansford7@gmail.com> wrote in message
news:kjhpld$fi6$1@newscl01ah.mathworks.com...
> "Rainaire" wrote in message <kjhpc2$eck$1@newscl01ah.mathworks.com>...

*snip*

> Ok so how do I do that? How do open the code for the figure and the
> figure also.

If you want to open a GUI named mygui2 from within your callback, use this
command:

mygui2

instead of this:

openfig('mygui2.fig')

The former does the initialization; the latter does not.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: String problem

From: Rainaire

Date: 8 Apr, 2013 16:30:14

Message: 7 of 8

"Steven_Lord" <slord@mathworks.com> wrote in message <kjht29$r4a$1@newscl01ah.mathworks.com>...
>
>
> "Rainaire " <rhansford7@gmail.com> wrote in message
> news:kjhpld$fi6$1@newscl01ah.mathworks.com...
> > "Rainaire" wrote in message <kjhpc2$eck$1@newscl01ah.mathworks.com>...
>
> *snip*
>
> > Ok so how do I do that? How do open the code for the figure and the
> > figure also.
>
> If you want to open a GUI named mygui2 from within your callback, use this
> command:
>
> mygui2
>
> instead of this:
>
> openfig('mygui2.fig')
>
> The former does the initialization; the latter does not.
>
> --
> Steve Lord
> slord@mathworks.com
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com
So for example if my program was called nair just put in my push button
nair
not
nair()
or
openfig('nair.fig')
How will Matlab recongize it?

Subject: String problem

From: Steven_Lord

Date: 10 Apr, 2013 17:00:01

Message: 8 of 8



"Rainaire " <rhansford7@gmail.com> wrote in message
news:kjuram$g5i$1@newscl01ah.mathworks.com...
> "Steven_Lord" <slord@mathworks.com> wrote in message
> <kjht29$r4a$1@newscl01ah.mathworks.com>...

*snip*

> So for example if my program was called nair just put in my push button
> nair
> not
> nair()

Those two are basically the same.

> or
> openfig('nair.fig')
> How will Matlab recongize it?

MATLAB will look in several different locations to determine the meaning of
the identifier "nair" based on this ordering.

http://www.mathworks.com/help/matlab/matlab_prog/function-precedence-order.html

As long as the nair function is in the current directory or on the MATLAB
path, it will find it at steps 8 or 9 (assuming that it doesn't find a
suitable nair function earlier in the list.)

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us