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:
GUI read a text file and

Subject: GUI read a text file and

From: roya olyazadeh

Date: 20 May, 2010 08:27:07

Message: 1 of 9

 I created a function in matlab. Input for this function is a text file .
Does anyone know how can I call a text file in GUI ??
 like this
filename=input('Input the filename :','s');

for example I want to click in a push button and then It asked me to write filename and directory and then I call my function.

And after running function , my results are displayed in axes and edit text that I drew in GUI.

Subject: GUI read a text file and

From: Varun

Date: 17 May, 2011 14:35:04

Message: 2 of 9

"roya olyazadeh" <roya2543@gmail.com> wrote in message <ht2ror$jnv$1@fred.mathworks.com>...
> I created a function in matlab. Input for this function is a text file .
> Does anyone know how can I call a text file in GUI ??
> like this
> filename=input('Input the filename :','s');
>
> for example I want to click in a push button and then It asked me to write filename and directory and then I call my function.
>
> And after running function , my results are displayed in axes and edit text that I drew in GUI.

Hi roya..
I hope you solved this problem.If so, please help me solving the similar kind of problem i have.

thanks
Grizzly

Subject: GUI read a text file and

From: wahyoe Unggul

Date: 17 May, 2011 17:58:03

Message: 3 of 9

"Varun" wrote in message <iqu12o$em6$1@newscl01ah.mathworks.com>...
> "roya olyazadeh" <roya2543@gmail.com> wrote in message <ht2ror$jnv$1@fred.mathworks.com>...
> > I created a function in matlab. Input for this function is a text file .
> > Does anyone know how can I call a text file in GUI ??
> > like this
> > filename=input('Input the filename :','s');
> >
> > for example I want to click in a push button and then It asked me to write filename and directory and then I call my function.
 
you can use uigetfile
wahyoe

Subject: GUI read a text file and

From: ImageAnalyst

Date: 17 May, 2011 18:04:50

Message: 4 of 9

No, I think he wants uiputfile() rather than uigetfile(). Here's a
snippet from one of my programs:

filterSpec = '*.*';
defaultName = sprintf('myDefaultTextFileName.txt');
dialogTitle = 'Save the data?';
[baseFileName, folder] = uiputfile(filterSpec, dialogTitle,
defaultName);
if baseFileName == 0
% User clicked cancel.
return; % Bail out.
end
fullFileName = fullfile(folder, baseFileName);

Subject: GUI read a text file and

From: Varun

Date: 17 May, 2011 18:37:02

Message: 5 of 9

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <447226e8-5f31-4e69-b322-55ec70456fb3@t19g2000yql.googlegroups.com>...
> No, I think he wants uiputfile() rather than uigetfile(). Here's a
> snippet from one of my programs:
>
> filterSpec = '*.*';
> defaultName = sprintf('myDefaultTextFileName.txt');
> dialogTitle = 'Save the data?';
> [baseFileName, folder] = uiputfile(filterSpec, dialogTitle,
> defaultName);
> if baseFileName == 0
> % User clicked cancel.
> return; % Bail out.
> end
> fullFileName = fullfile(folder, baseFileName);

Thank you guys..
I have one more question. i want to read through the frames in a file one by one using a GUI.Gui should have 5 buttons. Start,stop,pause,forward by one step and backward by one frame. can you please tell me the way to do it ?? i have used uiwait and uiresume for pause and staart again. but i cant see results when i Pause the program.
Thanks for your help
-- Grizzly

Subject: GUI read a text file and

From: ImageAnalyst

Date: 17 May, 2011 18:42:51

Message: 6 of 9

Grizzly:
Put this at the bottom of your loop over the frames:

promptMessage = sprintf('Do you want to Continue processing,\nor
Cancel to abort processing?');
button = questdlg(promptMessage, 'Continue', 'Continue', 'Cancel',
'Continue');
if strcmp(button, 'Cancel')
break;
end

Adapt in the obvious ways to set the frame number you want to process.

Subject: GUI read a text file and

From: ImageAnalyst

Date: 17 May, 2011 18:46:07

Message: 7 of 9

Or just have your 5 buttons. Each callback sets the relevant frame
number and then passes that into a common function

For example
% Get the frame number from a scroll bar
frameNumber = get(handles.scrollFrameNumber, 'Value');
% Now send that frame number into your analysis function.
resultsArray = AnalyzeSingleFrame(frameNumber);

Subject: GUI read a text file and

From: Varun

Date: 23 May, 2011 13:10:20

Message: 8 of 9

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <e82f8197-7d3a-4060-8211-24768e6fbabd@w10g2000yqa.googlegroups.com>...
> Or just have your 5 buttons. Each callback sets the relevant frame
> number and then passes that into a common function
>
> For example
> % Get the frame number from a scroll bar
> frameNumber = get(handles.scrollFrameNumber, 'Value');
> % Now send that frame number into your analysis function.
> resultsArray = AnalyzeSingleFrame(frameNumber);

Hi,
Thank you for the help. it worked really well.
i have one more doubt. In the GUI, i want to have a pull down menu for dispalying the figures of my choice. in my algorithm, the figure numbers varies with the kind of input file i am using. so, if i want to display all the figures and only figure one, or figure 2 or figure N, how can i do that ? please give me a suggestion.

thanks
varun

Subject: GUI read a text file and

From: ImageAnalyst

Date: 23 May, 2011 16:09:54

Message: 9 of 9

On May 23, 9:10 am, "Varun " <vvumm...@oakland.edu> wrote:
> Hi,
> Thank you for the help. it worked really well.
> i have one more doubt. In the GUI, i want to have a pull down menu for dispalying the figures of my choice. in my algorithm, the figure numbers varies with the kind of input file i am using. so, if i want to display all the figures and only figure one, or figure 2 or figure N, how can i do that ? please give me a suggestion.
>
> thanks
> varun

---------------------------------------------
GUIDE has a pulldown menu control that you can use and setup your
menus. You can have menu items checked or unchecked and you can check
the status and send the status into an "if" statement to do different
things.

Tags for this Thread

No tags are associated with 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