MATLAB Answers

0

only one column with pop up window and import data into row

Asked by Tobias Wzl on 18 Oct 2017
Latest activity Commented on by Tobias Wzl on 18 Oct 2017
I got it done now, that if I click on any cell a menu appears where I can select my file. But I just want this for a specific column and I also want that the filename appears in the cell in the colour blue.
For the import of the data I have to use the import-command right? If yes how can I include this into my code?
CODE:
function uitable1_CellSelectionCallback(hObject, eventdata)
datatable_row = eventdata.Indices(1);
datatable_col = eventdata.Indices(2);
Columndata = get(hObject,'Data');
[FileName,PathName] = uigetfile({'*.txt'; '*.csv'},'Select the configuration');
if strcmp(Columndata(1,1),'User Defined')
FilePath = fullfile(PathName,FileName);
if isequal(FileName,0)
return
end
[pathstr, name, ext] = fileparts(FilePath);
ParameterList{end+1} = name;
set(uitable1,'ColumnFormat',{ParameterList});
end
end

  0 Comments

Sign in to comment.

1 Answer

Answer by Jan
on 18 Oct 2017

1st question: "I just want this for a specific column"
Try this:
datatable_row = eventdata.Indices(1);
datatable_col = eventdata.Indices(2);
% Accept clicks on 2nd columns only:
if datatable_col ~= 2
return;
end
2nd question: "filename appears in the cell in the colour blue"
I have no idea, what this should do.
ParameterList{end+1} = name;
set(uitable1,'ColumnFormat',{ParameterList});
Is the name assumed to be a valid format?
Perhaps you mean
Columndata{datatable_col, datatable_row} = name;
And if you want to define the color:
str = ['<html><body color="#0000FF">', name '</body></html>']
Columndata{datatable_col, datatable_row} = str;

  5 Comments

my txt-files will contain numerical data, but with several rows and two columns (POWER [W]/Time the Power should be supplied)
Or do you think it would make more sense if when I have selected my file the whole data would be displayed in my cell? (hope you know what I mean by that) and after that the link to my file will be displayed at the bottom of the cell?
I am open to new proposals for a solution to this whole stuff.
In the other columns the values are entered by hand.
After this I want to save the whole setup into an other txt-file.
Is it really necessary to this undocumented java tricks you are referring to? Because I've never learned how to use JAVA.
You do not need Java, if you find another solution than hyper links in uitables.
Usually a uitable is used to display the contents of the file. But it is not clear yet, which data you want to display. E.g. why does the top left uitable cell contain the string 'User Defined'? What would be the purpose of the hyper link? Which function should be triggered by pressing it?
Can you create a sketch of how the GUI should look like?
clearly it should display the content of my file. is it possibly to display the path of my file in an seperate edit text box which is included in the uitable?
the cell with the contain 'user defined' was just some playing around in matlab and some stuff I found on the Internet.
the sketch of my gui: (this is just a prototype some things could be added and some things can disappear in the end)

Sign in to comment.