From: Garrett on
I am trying to use an edit text box to input a file name so that I can then read the file in when I use a push button.

Code:
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
c = get(handles.edit1,'string')
x = dlmread(c,' ');

I then get this error:

??? Error using ==> dlmread at 55
Filename must be a string.

Error in ==> untitled1>pushbutton1_Callback at 82
x = dlmread(c,' ');

As far as I can tell the error is happening because there is an extra set of apostrophes on each end of the filename I input.

So i input filename.asc into the edit text field of the GUI but when dlmread tries to access the variable c, which should just be the string in the edit field, it comes out as 'filename.asc'. Anyone know how to keep this extra set of apostrophes from showing up?

-Garrett
From: Garrett on
Nevermind I figured it out, just needs a char(get(handlestuff));
From: Jan Simon on
Dear Garrett,

> I am trying to use an edit text box to input a file name so that I can then read the file in when I use a push button.

> c = get(handles.edit1,'string')
> x = dlmread(c,' ');
> ??? Error using ==> dlmread at 55
> Filename must be a string.

You can use the debugger (e.g. "dbstop if error") to find out, that after
c = get(handles.edit1,'string')
c is a cell string and not a CHAR vector. Using CHAR converts a cell string to a string, as you have posted already. Another way would be:
name = c{1};
x = dlmread(c,' ')

Good luck, Jan
From: Garrett on
"Jan Simon" <matlab.THIS_YEAR(a)nMINUSsimon.de> wrote in message <i1d6n4$kjm$1(a)fred.mathworks.com>...
> Dear Garrett,
>
> > I am trying to use an edit text box to input a file name so that I can then read the file in when I use a push button.
>
> > c = get(handles.edit1,'string')
> > x = dlmread(c,' ');
> > ??? Error using ==> dlmread at 55
> > Filename must be a string.
>
> You can use the debugger (e.g. "dbstop if error") to find out, that after
> c = get(handles.edit1,'string')
> c is a cell string and not a CHAR vector. Using CHAR converts a cell string to a string, as you have posted already. Another way would be:
> name = c{1};
> x = dlmread(c,' ')
>
> Good luck, Jan


Thanks for the explanation, that makes more sense now. Is there a reason that after I push the calculate button I also have to hit enter in the command line for the dlmread to initialise?