I have a pop up menu that only has numbers to select but now i want one which has text. So how do i change this 'text' to a number to insert into my simulink model.
The code used for number pop up menu is:
allvalues = get(handles.popupmenu2,'String');
choiceidx = get(handles.popupmenu2,'Value');
if iscell(allvalues)
choicestr = allvalues{choiceidx};
else
choicestr = allvalues(choiceidx,:);
end
choice = str2double(choicestr);
set_param('mymodel/Lockup','Value',choicestr);
thanks
|
|
0
|
|
|
|
Reply
|
M
|
3/20/2010 10:08:02 PM |
|
"M " <mattyirwinasdasd@aol.com> wrote in message <ho3h02$pjq$1@fred.mathworks.com>...
> I have a pop up menu that only has numbers to select but now i want one which has text. So how do i change this 'text' to a number to insert into my simulink model.
> choice = str2double(choicestr);
well... CHOICE is a number; what's wrong with it(?)...
us
|
|
0
|
|
|
|
Reply
|
us
|
3/20/2010 10:23:03 PM
|
|
"us " <us@neurol.unizh.ch> wrote in message <ho3hs7$8fm$1@fred.mathworks.com>...
> "M " <mattyirwinasdasd@aol.com> wrote in message <ho3h02$pjq$1@fred.mathworks.com>...
> > I have a pop up menu that only has numbers to select but now i want one which has text. So how do i change this 'text' to a number to insert into my simulink model.
>
> > choice = str2double(choicestr);
>
> well... CHOICE is a number; what's wrong with it(?)...
>
> us
i want the pop up menu to be text. the text means a number which is then inputted to my model. Its not like the above code where there were numbers in the pop up menu
|
|
0
|
|
|
|
Reply
|
M
|
3/20/2010 10:32:04 PM
|
|
M wrote:
> "us " <us@neurol.unizh.ch> wrote in message
> <ho3hs7$8fm$1@fred.mathworks.com>...
>> "M " <mattyirwinasdasd@aol.com> wrote in message
>> <ho3h02$pjq$1@fred.mathworks.com>...
>> > I have a pop up menu that only has numbers to select but now i want
>> one which has text. So how do i change this 'text' to a number to
>> insert into my simulink model.
>>
>> > choice = str2double(choicestr);
>>
>> well... CHOICE is a number; what's wrong with it(?)...
> i want the pop up menu to be text. the text means a number which is then
> inputted to my model. Its not like the above code where there were
> numbers in the pop up menu
I've lost track of what you are trying to say.
Are you trying to say that the text in a pop-up entry might be a
variable name or formula, and you want to have that text evaluated and
set the parameter to the resulting value? Or nearly the same as that,
but the parameter should be set to the text representation of the
resulting number?
|
|
0
|
|
|
|
Reply
|
Walter
|
3/20/2010 11:22:50 PM
|
|
> I've lost track of what you are trying to say.
>
> Are you trying to say that the text in a pop-up entry might be a
> variable name or formula, and you want to have that text evaluated and
> set the parameter to the resulting value? Or nearly the same as that,
> but the parameter should be set to the text representation of the
> resulting number?
The text in the pop up menu is a fixed number value. for example if i had a pop up menu with 5 people names on it and i selected a name. when i ran the model it would load their age into it the simulink model.
|
|
0
|
|
|
|
Reply
|
M
|
3/20/2010 11:44:04 PM
|
|
"M " <mattyirwinasdasd@aol.com> wrote in message <ho3mk4$e88$1@fred.mathworks.com>...
>
> > I've lost track of what you are trying to say.
> >
> > Are you trying to say that the text in a pop-up entry might be a
> > variable name or formula, and you want to have that text evaluated and
> > set the parameter to the resulting value? Or nearly the same as that,
> > but the parameter should be set to the text representation of the
> > resulting number?
>
> The text in the pop up menu is a fixed number value. for example if i had a pop up menu with 5 people names on it and i selected a name. when i ran the model it would load their age into it the simulink model.
this is entirely confusing...
can you eventually come up with a frugal, intelligible example rather than a thousand unstructured words...
us
|
|
0
|
|
|
|
Reply
|
us
|
3/20/2010 11:58:04 PM
|
|
> > Are you trying to say that the text in a pop-up entry might be a
> > variable name or formula, and you want to have that text evaluated and
> > set the parameter to the resulting value? Or nearly the same as that,
> > but the parameter should be set to the text representation of the
> > resulting number?
you are correct, this is what i am looking for.
|
|
0
|
|
|
|
Reply
|
M
|
3/21/2010 12:06:03 AM
|
|
"M " <mattyirwinasdasd@aol.com> wrote in message <ho3ntb$307$1@fred.mathworks.com>...
> > > Are you trying to say that the text in a pop-up entry might be a
> > > variable name or formula, and you want to have that text evaluated and
> > > set the parameter to the resulting value? Or nearly the same as that,
> > > but the parameter should be set to the text representation of the
> > > resulting number?
>
> you are correct, this is what i am looking for.
huh(!)...
you're getting more confusing by the minute...
in your last reply to the very same question, you said
....
The text in the pop up menu is a fixed number value. for example if i had a pop up menu with 5 people names on it and i selected a name. when i ran the model it would load their age into it the simulink model.
....
this time, your answer is completely(to say the least!) different...
your behavior is tedious; can you make up your mind...
us
|
|
0
|
|
|
|
Reply
|
us
|
3/21/2010 12:17:04 AM
|
|
"us " <us@neurol.unizh.ch> wrote in message <ho3oi0$e9o$1@fred.mathworks.com>...
> "M " <mattyirwinasdasd@aol.com> wrote in message <ho3ntb$307$1@fred.mathworks.com>...
> > > > Are you trying to say that the text in a pop-up entry might be a
> > > > variable name or formula, and you want to have that text evaluated and
> > > > set the parameter to the resulting value? Or nearly the same as that,
> > > > but the parameter should be set to the text representation of the
> > > > resulting number?
> >
> > you are correct, this is what i am looking for.
>
> huh(!)...
> you're getting more confusing by the minute...
> in your last reply to the very same question, you said
> ...
> The text in the pop up menu is a fixed number value. for example if i had a pop up menu with 5 people names on it and i selected a name. when i ran the model it would load their age into it the simulink model.
> ...
> this time, your answer is completely(to say the least!) different...
> your behavior is tedious; can you make up your mind...
>
> us
my behaviour is tedious! are you drunk. sort it out
It is not 'completely' different. It is saying....the TEXT in the pop up menu is EQUIVALENT to a number value which is what walter was describing
|
|
0
|
|
|
|
Reply
|
M
|
3/21/2010 12:29:06 AM
|
|
M wrote:
>
>> I've lost track of what you are trying to say.
>>
>> Are you trying to say that the text in a pop-up entry might be a
>> variable name or formula, and you want to have that text evaluated and
>> set the parameter to the resulting value? Or nearly the same as that,
>> but the parameter should be set to the text representation of the
>> resulting number?
>
> The text in the pop up menu is a fixed number value. for example if i
> had a pop up menu with 5 people names on it and i selected a name. when
> i ran the model it would load their age into it the simulink model.
function generalized_popup_callback( src, evt, valuelist, paramname )
set_param( paramname, valuelist{get(src, 'Value')} );
end
namelist = {'Frank', 'Sam', 'Linda'};
agelist = {35 42 29};
birthplacelist = {'Kyoto', 'Windsor', 'Brisbane'};
uicontrol( 'Style', 'popup', 'String', namelist, ...
'Callback', {@generalized_popup_callback, agelist, 'mymodel/age'});
uicontrol( 'Style', 'popup', 'String', namelist, ...
'Callback', {@generalized_popup_callback, birthplacelist,
'mymodel/birthplace'});
|
|
0
|
|
|
|
Reply
|
Walter
|
3/21/2010 1:23:19 AM
|
|
Walter Roberson <roberson@hushmail.com> wrote in message <ho3se8$hj3$1@canopus.cc.umanitoba.ca>...
> M wrote:
> >
> >> I've lost track of what you are trying to say.
> >>
> >> Are you trying to say that the text in a pop-up entry might be a
> >> variable name or formula, and you want to have that text evaluated and
> >> set the parameter to the resulting value? Or nearly the same as that,
> >> but the parameter should be set to the text representation of the
> >> resulting number?
> >
> > The text in the pop up menu is a fixed number value. for example if i
> > had a pop up menu with 5 people names on it and i selected a name. when
> > i ran the model it would load their age into it the simulink model.
>
> function generalized_popup_callback( src, evt, valuelist, paramname )
> set_param( paramname, valuelist{get(src, 'Value')} );
> end
>
> namelist = {'Frank', 'Sam', 'Linda'};
> agelist = {35 42 29};
> birthplacelist = {'Kyoto', 'Windsor', 'Brisbane'};
>
> uicontrol( 'Style', 'popup', 'String', namelist, ...
> 'Callback', {@generalized_popup_callback, agelist, 'mymodel/age'});
>
> uicontrol( 'Style', 'popup', 'String', namelist, ...
> 'Callback', {@generalized_popup_callback, birthplacelist,
> 'mymodel/birthplace'});
Walter, im not quite sure if you know what i mean. sorry if it has been unclear.
I have a pop up menu which when you click on the arrow it has the list of text (lets say names) that i inputted in the string of the pop up menu.
Now what i want to happen is when this text (a name) is slected from the list and run the GUI it changes this text to a number value i have assigned to it.
What i want to know is how do i assign this text a number?
|
|
0
|
|
|
|
Reply
|
M
|
3/21/2010 1:50:04 AM
|
|
M wrote:
> "us " <us@neurol.unizh.ch> wrote in message
> <ho3oi0$e9o$1@fred.mathworks.com>...
>> this time, your answer is completely(to say the least!) different...
>> your behavior is tedious; can you make up your mind...
> my behaviour is tedious! are you drunk. sort it out
M, the only reason *I* was able to figure out what you might mean is
that I'm an obsessive paranoid, turning words around and around and
around in my head to try to figure out what people _really_ mean. And
even -I- nearly dropped out of the conversation because you were being
fairly incomprehensible. If I'd been asked to go out shopping or do some
cleaning or what-ever instead of having the afternoon with nothing
better to do, then you wouldn't have heard back from me.
If you want answers from people, you have to find better and more
consistent ways to express yourself. It doesn't even have to be in
English, but if it is not in English, the number of readers who will be
able to understand what you write will drop considerably.
|
|
0
|
|
|
|
Reply
|
Walter
|
3/21/2010 2:07:36 AM
|
|
M wrote:
> Walter, im not quite sure if you know what i mean. sorry if it has been
> unclear.
> I have a pop up menu which when you click on the arrow it has the list
> of text (lets say names) that i inputted in the string of the pop up menu.
> Now what i want to happen is when this text (a name) is slected from the
> list and run the GUI it changes this text to a number value i have
> assigned to it.
> What i want to know is how do i assign this text a number?
Well, if you insist... but I think you have not understood the power and
flexibility of the generalized callback I suggested.
function generalized_popup_callback( src, evt, valuelist, paramname )
set_param( paramname, valuelist{get(src, 'Value')} );
end
namelist = {'Frank', 'Sam', 'Linda'};
Frank = 35;
Sam = 42;
Linda = 29;
agelist = {Frank Sam Linda};
uicontrol( 'Style', 'popup', 'String', namelist, ...
'Callback', {@generalized_popup_callback, agelist, 'mymodel/age'});
|
|
0
|
|
|
|
Reply
|
Walter
|
3/21/2010 2:17:01 AM
|
|
"M " <mattyirwinasdasd@aol.com> wrote in message <ho3p8i$18d$1@fred.mathworks.com>...
> "us " <us@neurol.unizh.ch> wrote in message <ho3oi0$e9o$1@fred.mathworks.com>...
> > "M " <mattyirwinasdasd@aol.com> wrote in message <ho3ntb$307$1@fred.mathworks.com>...
> > > > > Are you trying to say that the text in a pop-up entry might be a
> > > > > variable name or formula, and you want to have that text evaluated and
> > > > > set the parameter to the resulting value? Or nearly the same as that,
> > > > > but the parameter should be set to the text representation of the
> > > > > resulting number?
> > >
> > > you are correct, this is what i am looking for.
> >
> > huh(!)...
> > you're getting more confusing by the minute...
> > in your last reply to the very same question, you said
> > ...
> > The text in the pop up menu is a fixed number value. for example if i had a pop up menu with 5 people names on it and i selected a name. when i ran the model it would load their age into it the simulink model.
> > ...
> > this time, your answer is completely(to say the least!) different...
> > your behavior is tedious; can you make up your mind...
> >
> > us
>
> my behaviour is tedious! are you drunk. sort it out
> It is not 'completely' different. It is saying....the TEXT in the pop up menu is EQUIVALENT to a number value which is what walter was describing
well...
let me just add this before leaving your thread for good:
your behavior is not boding well for a successful future here at CSSM...
firstly, i am not drunk...
second, it is YOU who has to sort things out before wasting CSSMers time...
us
|
|
0
|
|
|
|
Reply
|
us
|
3/21/2010 11:46:03 AM
|
|
|
13 Replies
221 Views
(page loaded in 0.117 seconds)
Similiar Articles: Convert DATE to NUMBER - comp.lang.awkPlease help.... Convert text to number in pop up menu - comp.soft ... Convert DATE to NUMBER - comp.lang.awk Please help.... Convert text to number in pop up menu - comp ... Set popup menu string list (in guide) from structure - comp.soft ...Please help.... Convert text to number in pop up menu - comp.soft ... Set popup menu string list (in guide) from structure - comp.soft ... Please help.... speech to text conversion using matlab. - comp.soft-sys.matlab ...Text to Voice conversion in matlab - comp.soft-sys.matlab ... Please help.... Convert text to number in pop up menu - comp.soft ... can u help to execute the matlab ... Geocoding- converting addresses to Latitude and longitudes - comp ...I was wondering if anybody could explain how to convert an ... is a general javascript group and they can better help ... Speed-up the reading of large binary files with ... Copying highlighted text - comp.text.pdfPlease help.... Convert text to number in pop up menu - comp.soft ... Copying highlighted text - comp.text.pdf Please help.... Convert text to number in pop up menu - comp ... Text to Voice conversion in matlab - comp.soft-sys.matlab ...Convert text to number in pop up menu - comp.soft ... Text to Voice conversion in matlab - comp.soft-sys.matlab ... Please help.... Convert text to number in pop up menu ... Converting pain text to TeX - comp.lang.awkConvert text to number in pop up menu - comp.soft ... Converting a string formula to TeX - comp.lang.java.programmer ... Please help.... Convert text to number in pop ... Converting a string formula to TeX - comp.lang.java.programmer ...Converting a string formula to TeX - comp.lang.java.programmer ... Please help.... Convert text to number in pop up menu - comp.soft ... > of text (lets say names) that i ... Convert a simulink model to excel - comp.soft-sys.matlab ...Please help.... Convert text to number in pop up menu - comp.soft ... So how do i change this 'text' to a number to insert into my simulink model. ... How to use a popup menu value inside a function in a GUI? - comp ...Please help.... Convert text to number in pop up menu - comp.soft ... I have a pop up menu ... run the GUI it changes this text to a number value i ... is a pop up ... Execute a FORMULA in text variable - comp.lang.xharbourPlease help.... Convert text to number in pop up menu - comp.soft ..... the text in a pop-up entry might be a variable name or formula, and you want to have that text ... Starting a .mvba file in microstation - comp.cad.microstation ...As a BTW, we host and monitor a number of discussion ... Please help! - comp ... Starting a .mvba file in microstation ... White screen at start up then nothing else ... Extract Program change number formula - comp.music.midiPlease help.... Convert text to number in pop up menu - comp.soft ... Extract Program change number formula - comp.music.midi Please help.... Convert text to number in pop ... MATLAB: How do you simulate a simulink model using a string ...Hey guys can you please help with this, I just cant get it. I ... Please help.... Convert text to number in pop up menu - comp.soft ... So how do i change this 'text' to ... Raise a variable to the power of another variable in Simulink ...> > Thank you in advance, > AL Hi, Math function Block, http://www.mathworks.com/help/toolbox/simulink/slref/mathfunction.html use the "power" option. Thread Subject: Please help.... Convert text to number in pop up menuI have a pop up menu that only has numbers to select but now i want one which has text. So how do i change this 'text' to a number to insert into my simulink model. Excel - Convert Text To Numbers Via Vba - Im sure my issue ...Please help, before I throw my laptop out of the window. Regards, James ... of the entire selected area, and from the resulting pop-up menu, select "Convert text to number". 7/10/2012 5:55:30 PM
|