MATLAB Answers

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

조회 수: 3(최근 30일)
Tobias Wzl
Tobias Wzl 18 Oct 2017
댓글: Tobias Wzl 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

댓글을 달려면 로그인하십시오.

답변(1개)

Jan
Jan 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

표시 이전 댓글 수: 2
Tobias Wzl
Tobias Wzl 18 Oct 2017
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.
Jan
Jan 18 Oct 2017
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?
Tobias Wzl
Tobias Wzl 18 Oct 2017
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)

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by