From: M on
The values are loaded into the pop up menu and are working, when i click simulate i want it to load this value into my model

popupmenu1 = get(handles.popupmenu1, 'Value')
set_param(mymodel/lockout','Value',popupmenu1);

This does not work, what do i need to do?

thanks
From: M on
anybody help here?
From: Walter Roberson on
M wrote:
> The values are loaded into the pop up menu and are working, when i click
> simulate i want it to load this value into my model
>
> popupmenu1 = get(handles.popupmenu1, 'Value')
> set_param(mymodel/lockout','Value',popupmenu1);
>
> This does not work, what do i need to do?

The Value is the index down into the menu, not the content of the line
you selected.

allvalues = get(handles.popupmenu1,'String');
choiceidx = get(handles.popupmenu1,'Value');
if iscell(allvalues)
choicestr = allvalues{choiceidx};
else
choicestr = allvalues(choiceidx,:);
end
choice = str2double(choicestr);
set_param('mymodel/lockout','Value',choice);
From: M on
Walter Roberson <roberson(a)hushmail.com> wrote in message <ho2np4$kk9$1(a)canopus.cc.umanitoba.ca>...
> M wrote:
> > The values are loaded into the pop up menu and are working, when i click
> > simulate i want it to load this value into my model
> >
> > popupmenu1 = get(handles.popupmenu1, 'Value')
> > set_param(mymodel/lockout','Value',popupmenu1);
> >
> > This does not work, what do i need to do?
>
> The Value is the index down into the menu, not the content of the line
> you selected.
>
> allvalues = get(handles.popupmenu1,'String');
> choiceidx = get(handles.popupmenu1,'Value');
> if iscell(allvalues)
> choicestr = allvalues{choiceidx};
> else
> choicestr = allvalues(choiceidx,:);
> end
> choice = str2double(choicestr);
> set_param('mymodel/lockout','Value',choice);

Thank you for your reply. I am getting an error

??? Error using ==> GUI>pushbutton1_Callback at 119
Invalid setting in Constant block 'lockout' for parameter 'Value'.
From: Walter Roberson on
M wrote:
> Walter Roberson <roberson(a)hushmail.com> wrote in message
> <ho2np4$kk9$1(a)canopus.cc.umanitoba.ca>...
>> M wrote:
>> > The values are loaded into the pop up menu and are working, when i
>> click > simulate i want it to load this value into my model
>> > > popupmenu1 = get(handles.popupmenu1, 'Value')
>> > set_param(mymodel/lockout','Value',popupmenu1);
>> > > This does not work, what do i need to do?
>>
>> The Value is the index down into the menu, not the content of the line
>> you selected.
>>
>> allvalues = get(handles.popupmenu1,'String');
>> choiceidx = get(handles.popupmenu1,'Value');
>> if iscell(allvalues)
>> choicestr = allvalues{choiceidx};
>> else
>> choicestr = allvalues(choiceidx,:);
>> end
>> choice = str2double(choicestr);
>> set_param('mymodel/lockout','Value',choice);
>
> Thank you for your reply. I am getting an error
>
> ??? Error using ==> GUI>pushbutton1_Callback at 119
> Invalid setting in Constant block 'lockout' for parameter 'Value'.

Sorry, I don't know Simulink and models at all, and so have no idea what
kind of value needs to be used in set_param for that parameter. Possibly
passing it choicestr instead of choice would work... I don't know. If
your choices are not numeric then you certain do not want the str2double
step.