File name entry into gui table

Asked by Derrick Salmon on 14 Aug 2012
Latest activity Commented on by Walter Roberson on 15 Aug 2012

GUIDE newbie questions

Using GUIDE, I cannot figure out how to enter a file name acquired through uigetfile into a table cell. Any halp for this simple funciton greatly appreciated.

1 Comment

Azzi Abdelmalek on 14 Aug 2012

what do you mean enter a file name acquired through uigetfile into a table cell

Derrick Salmon

Tags

Products

No products are associated with this question.

2 Answers

Answer by Walter Roberson on 14 Aug 2012
Accepted answer
filename = uigetfile('*.jpg'); %for example
curdata = get(handles.uitable1, 'Data');  %example handle name
curdata{3,2} = filename;    %3,2 is example location
set(handles.uitable1, 'Data', curdata);   %same example handle name

2 Comments

Derrick Salmon on 15 Aug 2012

Hi Walter

Thanks for your help earlier.. The comment field would not open before, but it has now, so here here goes.

Your example worked well, but I need to be able to select a cell using the mouse into which to put the file name rather than pre-assigning a cell position.

I've tried the following in uitable1_CellEditCallback:

    handles.fpointer = get(handles.uitable1,'Indices')
    guidata(hObject, handles);

to get the cell indices, but Matlab reports:

Error using hg.uitable/get
The name 'Indices' is not an accessible property for an instance of class
'uitable'.

Error in test>uitable1_CellSelectionCallback (line 96) handles.fpointer = get(handles.uitable1,'Indices')

Not quite sure where to go next

D.

Walter Roberson on 15 Aug 2012

Indices is a field of the eventdata that gets passed to the callback.

Walter Roberson
Answer by Image Analyst on 14 Aug 2012

How about

dataTable = {'FileName'; filename};
set(handles.uitable1, 'data', dataTable);

1 Comment

Derrick Salmon on 15 Aug 2012

Hi Image Analyst

Thanks for the answer. It got me thinking 'handles' better, but ended up converting the table to a single entry. Go figure.

Anyway, I'm starting to see that the black abyss called MatLab GUI Programming is actually clear water for those willing to spend the time - but they remain somewhat murky still for me at the moment, but clearing.

cheers

D.

Image Analyst

Contact us