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:
How to pass parameters from text box to m file function

Subject: How to pass parameters from text box to m file function

From: Muhammad Nawaz

Date: 27 Sep, 2010 13:41:21

Message: 1 of 2

Hi,

I have a matlab program and have developed a GUI for it. Now i want to run my program from my GUI and pass some parameters to the function in the m file. My problem is like this:

The matlab program runs a video file from my hard drive: obj = mmreader('paris_cif.avi');
 and
selects a specified frame from the video via : rgb_img = read(obj,2);
where i specify the frame number in the second parameter read(, 2), means frame number 2 will be selected and displayed later.

I have developed a GUI where i have put tex box which prompts to enter the frame number i want to fetch from the video.

How can i specify in the Matlab program(.m file) to read the data(frame number) from the text box.

More specifically, what should be the parameter in rgb_img=read(obj, ?? ) , if i want to read from the text box instead of putting it static.

Thanks

Subject: How to pass parameters from text box to m file function

From: Sean

Date: 27 Sep, 2010 17:07:21

Message: 2 of 2


> How can i specify in the Matlab program(.m file) to read the data(frame number) from the text box.
>
> More specifically, what should be the parameter in rgb_img=read(obj, ?? ) , if i want to read from the text box instead of putting it static.

Set the handles of the textbox to appdata, i.e.:

setappdata(0,'Hmy_textbox',handles.TextBox1);

Then in your mfile retrieve:

Hmy_textbox = getappdata(0,'Hmu_textbox')l
my_value = str2double(get(Hmy_textbox,'String'));
rgb_img=read(obj, my_value ); %Not sure about this part.

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