Import txt/csv into a cell of a column
1视图(最近30天)
Show older comments
大家好,
this is my code I'm struggling with:
% --- FIGURE -------------------------------------
handles.figure1 = figure(...
'Tag','图1',...
'单位','characters',...
'位置', [102.8 24.2307692307692 126.8 33],...
的名字','Parameter',...
'菜单栏','数字',...
'NumberTitle','off',...
'颜色', [0.941 0.941 0.941]);
% --- UITABLE -------------------------------------
% Initialize empty string for components of the Data
Data=cell(16,5);
fori = 1:numel(Data)
Data{i} ='';
end
uitable1 = uitable(...
“父母”, handles.figure1,...
'Tag','uitable1',...
'UserData', zeros(1,0),...
'单位','characters',...
'位置', [12.2 8 85.6 21],...
'背景颜色',[1 1 1; 0.961 0.961 0.961],,...
“可弄脏”, [true,true,true,true,true],...
'ColumnFormat', {'char','char','char','char','char'},...
'ColumnName',{'ID','Pi -stationary
[W]',' p i - 传播
[w/t]','&Omega','V'},...% 'Pi[W]'für griechische Buchstaben in einer Column &Buchstabe
[W]',' p i - 传播
[w/t]','&Omega','V'},...% 'Pi[W]'für griechische Buchstaben in einer Column &Buchstabe
'ColumnWidth', {'auto','auto','auto','auto','auto'},...
'数据',Data);%添加“字符串”数据
功能uitable1_CellEditCallback(hObject, eventdata, handles)
Columndata = get(hObject,'数据');
[filename,pathname] = uigetfile({{'*.txt';'*.csv'},'Select the configuration');
ifstrcmp(Columndata(1,1),'User Defined')
FilePath = fullfile(PathName,FileName);
ifisequal(FileName,0)
return
end
[pathstr, name, ext] = fileparts(FilePath);
ParameterList{end+1} = name;
set(uitable1,'ColumnFormat',{ParameterList});
end
end
我需要哪个命令,以便我可以将TXT或CSV文件导入列的单元格(应该适用于列P_I-Transient的所有单元格)
tried it with importdata or fopen and it didnt work for me, I think I used it wrong :( can somebody help me with the right command(s) and where to put them?
Accepted Answer
Arvind Narayanan
on 23 Oct 2017
嗨,托比亚斯,
尽管没有直接的方法可以分配不同列中的单元格,但您可以使用
eventdata
structure from the
CellEditCallback
and the
CellSelectionCallback
找到所选择的单元格的行和列索引。在此之后,您可以定义一些条件循环语句,以便根据行或列索引(根据您的要求)不同。
To control the color of the text that appears in the cell, change the Foreground Color property from within the above-mentioned callback itself.
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
开始狩猎!