Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: how to read from 'set'

Subject: how to read from 'set'

From: mark b.

Date: 19 Jun, 2008 12:48:01

Message: 1 of 13

hi,
i've got such a question:
this line of a code gets me the value that is returnet by
function 'update':

set(handles.figure1,'windowbuttondownfcn','p=update')

but now i want to put whis value (p) into some variable, so
that i can use it later.but i do not know how.
can anyone suggest me anything?

 kind regards

Subject: how to read from 'set'

From: Ian Clarkson

Date: 19 Jun, 2008 13:14:03

Message: 2 of 13

"mark b." <john.doe.nospam@mathworks.com> wrote in message
<g3dki1$of8$1@fred.mathworks.com>...
> hi,
> i've got such a question:
> this line of a code gets me the value that is returnet by
> function 'update':
>
> set(handles.figure1,'windowbuttondownfcn','p=update')
>
> but now i want to put whis value (p) into some variable, so
> that i can use it later.but i do not know how.
> can anyone suggest me anything?
>
> kind regards

get(handles.figure1,'WindowButtonDownFcn') may work,
assuming i've understood your query properly.

Subject: how to read from 'set'

From: mark b.

Date: 19 Jun, 2008 13:20:19

Message: 3 of 13

i tried it, but it returns me:
ans =

p=update;

and i need the values in 'p'

Subject: how to read from 'set'

From: Steven Lord

Date: 19 Jun, 2008 13:26:47

Message: 4 of 13


"mark b." <john.doe.nospam@mathworks.com> wrote in message
news:g3dki1$of8$1@fred.mathworks.com...
> hi,
> i've got such a question:
> this line of a code gets me the value that is returnet by
> function 'update':
>
> set(handles.figure1,'windowbuttondownfcn','p=update')
>
> but now i want to put whis value (p) into some variable, so
> that i can use it later.but i do not know how.
> can anyone suggest me anything?

When you write a callback like this, the string you SET as your
WindowButtonDownFcn is executed as though you typed it at the command line,
so the variable p is created in the base workspace.

Instead, I'd recommend either modifying the update function so that it
stores the value it would have output in the figure's UserData property or
in the handles structure (using GUIDATA and/or GUIHANDLES) or explicitly
setting the output into UserData in the callback.


set(handles.figure1,'windowbuttondownfcn','set(handles.figure1,
''UserData'', update)')


Then access either the handles structure or the figure's UserData property
to access the output of the update function.

--
Steve Lord
slord@mathworks.com


Subject: how to read from 'set'

From: mark b.

Date: 19 Jun, 2008 13:46:01

Message: 5 of 13

set(handles.figure1,'windowbuttondownfcn','set
(handles.figure1, ''UserData'', update)')

it returns me
??? Undefined variable "handles" or class "handles.figure1".


Subject: how to read from 'set'

From: Jos

Date: 19 Jun, 2008 14:37:01

Message: 6 of 13

"mark b." <john.doe.nospam@mathworks.com> wrote in message
<g3dnup$43c$1@fred.mathworks.com>...
> set(handles.figure1,'windowbuttondownfcn','set
> (handles.figure1, ''UserData'', update)')
>
> it returns me
> ??? Undefined variable "handles" or class "handles.figure1".
>
>

help GCBF

as in

set(h.f1,'..','set(gcbf,''userdata'',update)') ;

Jos

Subject: how to read from 'set'

From: mark b.

Date: 19 Jun, 2008 14:59:02

Message: 7 of 13

but such a thing:

 set(handles.figure1,'windowbuttondownfcn','set
(gcbf, ''UserData'', update)')
get(handles.figure1, 'UserData')


returns me:
ans =

   Empty matrix: 1-by-0

Subject: how to read from 'set'

From: mark b.

Date: 19 Jun, 2008 18:02:01

Message: 8 of 13

i've noticed that
set(handles.figure1,'windowbuttondownfcn','set
(gcbf, ''UserData'', update)')
    get(handles.figure1, 'UserData')

is done in the same time, so that is the reason
    get(handles.figure1, 'UserData')
returns me an empty matrix. but when i try to do it for
example:

if (set(handles.figure1,'windowbuttondownfcn','set
(gcbf, ''UserData'', update)'))

    get(handles.figure1, 'UserData')

end

it returns me: > modelGUI
??? Error using ==> set
One or more output arguments not assigned during call
to "set".

can anyone help me with that?

Subject: how to read from 'set'

From: mark b.

Date: 19 Jun, 2008 18:02:02

Message: 9 of 13

i've noticed that
set(handles.figure1,'windowbuttondownfcn','set
(gcbf, ''UserData'', update)')
    get(handles.figure1, 'UserData')

is done in the same time, so that is the reason
    get(handles.figure1, 'UserData')
returns me an empty matrix. but when i try to do it for
example:

if (set(handles.figure1,'windowbuttondownfcn','set
(gcbf, ''UserData'', update)'))

    get(handles.figure1, 'UserData')

end

it returns me: > modelGUI
??? Error using ==> set
One or more output arguments not assigned during call
to "set".

can anyone help me with that?

Subject: how to read from 'set'

From: mark b.

Date: 19 Jun, 2008 18:02:43

Message: 10 of 13

i've noticed that
set(handles.figure1,'windowbuttondownfcn','set
(gcbf, ''UserData'', update)')
    get(handles.figure1, 'UserData')

is done in the same time, so that is the reason
    get(handles.figure1, 'UserData')
returns me an empty matrix. but when i try to do it for
example:

if (set(handles.figure1,'windowbuttondownfcn','set
(gcbf, ''UserData'', update)'))

    get(handles.figure1, 'UserData')

end

it returns me: > modelGUI
??? Error using ==> set
One or more output arguments not assigned during call
to "set".

can anyone help me with that?

Subject: how to read from 'set'

From: Zhelyazko

Date: 19 Jun, 2008 21:04:02

Message: 11 of 13

Why don't you just change your update function?

function update
fig=gcbf;
%your original function
.............
set(fig,'UserData',p);


Subject: how to read from 'set'

From: mark b.

Date: 20 Jun, 2008 08:28:01

Message: 12 of 13

finally!! :)

thank You very much:)

Subject: how to read from 'set'

From: mark b.

Date: 20 Jun, 2008 08:49:01

Message: 13 of 13

hmm, i think i was happy too fast.

actually it doesn't work and really do not know what to do
with this. my update function(that is not GUI!!):

function p= update
fig=gcbf;
%my function
.............
set(fig,'UserData',p);

function in GUI:

function setMouse_Callback(hObject, eventdata, handles)

set(handles.figure1,'windowbuttondownfcn','set
(gcbf, ''UserData'', update)')
points = { get(gcbf, 'UserData')}


 or

set(handles.figure1,'windowbuttondownfcn','update;')
points = { get(gcbf, 'UserData')}


or

points = { get(gcbf, 'UserData')}


all of this returns me only

    [1x0 double]



do You maybe know what still is wrong?

kind regards,

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.
Related Topics