Thread Subject: Help on GUI code

Subject: Help on GUI code

From: M

Date: 20 Mar, 2010 02:30:20

Message: 1 of 4

Hi, can someone please help with my project.

On my GUI i have a text box and a push button. The string of the box is called value1.


CODE:

function value1_Callback(hObject, eventdata, handles)

function value1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function pushbutton1_Callback(hObject, eventdata, handles)
set_param('model3/Constant5','Value', 'value1');


When i run this m file it opens the GUI window. However no matter what i type in the text box and press the push button the value that loads into the constant5 block on my model is the word 'value1'.
How do i make it so that it loads what i want from my text box in the GUI and not the actual 'value1' word?

thanks

Subject: Help on GUI code

From: ImageAnalyst

Date: 20 Mar, 2010 03:34:08

Message: 2 of 4

I don't know what your set_param(') does, but why don't you try it
this way

value1 = get(handles.value1, 'String'); % Retrieve the value.
dblValue1 = str2double(value1); % Convert string to a number if
necessary

set_param('model3/Constant5','Value', value1);

Or...
set_param('model3/Constant5','Value', dblValue1);

Subject: Help on GUI code

From: M

Date: 20 Mar, 2010 03:36:04

Message: 3 of 4

anybody help???

Subject: Help on GUI code

From: M

Date: 20 Mar, 2010 03:58:02

Message: 4 of 4

thankfully....it works

thanks soo much

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

Contact us at files@mathworks.com