Doubles and cell array in uitable

조회 수: 15 (최근 30일)
cdr
cdr 2015년 4월 21일
편집: cdr 2015년 4월 22일
trying to get variable double arrays and one (1xn) cell array in an uitable.
Error: Error using uitable Values within a cell array must be numeric, logical, or char
if i try to convert it i get the following error:
Error: data within a cell array must have size [1 1]
that´s my data and uitable:
dat = [double1' double2' 1xNcell double3'];
f = figure('Position',[100 100 1000 500]);
columnformat = {'numeric','numeric',{'c' 'd'},'numeric'};
cnames = {'1','2', 'string','3'};
t = uitable('Parent',f, 'ColumnName',cnames, 'Position',[25 50 950 450],'Data', dat)
Can someone help me out?

채택된 답변

Image Analyst
Image Analyst 2015년 4월 21일
columnformat is a cell array. Three of the 4 cells in columnformat are simple strings. However the third cell contains another cell . Why? It should not. Have you read the FAQ: http://matlab.wikia.com/wiki/FAQ#What_is_a_cell_array.3F
Also, in this line
dat = [double1' double2' 1xNcell double3'];
that won't work if 1xNcell is really a cell array instead of a double array like the other 3. I recommend you split your data up into all doubles, or if you need mixed class data, use one cell array for dat. Either way, you should not have a cell within a cell for columnformat.
  댓글 수: 1
cdr
cdr 2015년 4월 22일
편집: cdr 2015년 4월 22일
Thanks but i still get an error:
Error using set Data within a cell array must have size [1 1]
I used one cell array for dat, including the doubles using num2cell for each (1xn)double array and the string is now included as char. This leads to the error: using uitable Values within a cell array must be numeric, logical, or char
that means i can not use cells for my uitable. It works when i just type in the char in dat={char(1)} but adding more values created an error.
furthermore the chars should be acessed individually (char(i)) and not be written as one string containing all the chars but just whar i entered in the corresponding edit box.
My code now looks like that:
dataCell={Tonstring}; %{}containing a 1x2 cell
A1={double1}; %{}containing a 1x2 double
dat=[A1 dataCell];
set(t, 'Data', dat);

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by