Hallo! I have this table wich consists of two columns one singe(AlplaParameter) and one double(ConfidenceInt)
I used this command in order export the table as figure
uitable('Data',T{:,:},'ColumnName',T.Properties.VariableNames,'RowName',T.Properties.RowNames,'Units', 'Normalized', 'Position',[0, 0, 1, 1]);
Unfortunatelly, the second column is transformed to two single columns leaving the column name empty. Here is a picture that illustates the problem:
How can I merge the title cells of 2nd and 3rd column?

 채택된 답변

Walter Roberson
Walter Roberson 2018년 1월 16일

1 개 추천

That is not possible with uitable.
  • You can set the Data to a numeric array, in which case each array element will be made into a separate entry, same as if you had set the data to num2cell() of the numeric array
  • You can set the Data to a cell array. Each entry in the cell array must be either a numeric scalar or a logical scalar or a string() scalar or a character (row) vector. It is not possible to set an entry to be a 1 x 2 numeric array.
The closest you could get to this is to convert the entries for the dual column into character, such as
data = [num2cell(YourTable.AlpaParameter), cellstr(num2str(YourTable.ConfidenceInt))];
uitable(...', 'Data', data)

댓글 수: 6

Panos Ale
Panos Ale 2018년 1월 16일
Thanks! It works!Is it also possible to clarify to my how can I place the contents of each column to center of it? They are are the right edge of the column and this makes it confusing!
data1 = num2cell(YourTable.AlpaParameter);
data2 = sprintfc('<HTML><table border=0 width=150><td><CENTER>%10.4f %10.4f', YourTable.ConfidenceInt);
data = [data1, data2];
Note: adjust the 150 as appropriate for the width of your cell.
Note: the undocumented sprintfc uses the format items along rows, which is unlike fprintf and sprintf, both of which use format items along columns
Panos Ale
Panos Ale 2018년 1월 17일
Thank you very much!!This is excactly what I needed!!But is seems that I need to increase the interval intervals between the valiables of the second column because they seem to be unseparated!
Walter Roberson
Walter Roberson 2018년 1월 17일
I used data values in about the same range as what you had posted and the values looked separated enough to me, perhaps more than was needed. The main issue I encountered was that when I constructed the uitable I did not specify the width of the columns so most of the second column got cut off with the default column size.
Panos Ale
Panos Ale 2018년 1월 17일
편집: Panos Ale 2018년 1월 17일
Thanks you again for your response! This image illustrates the problem I am talking about:
Is there a way to solve this problem? Or maybe another way to create a table figure?
Is it possible that you changed the font for the uitable to something that is proportionally spaced?
The code I gave,
data2 = sprintfc('<HTML><table border=0 width=150><td><CENTER>%10.4f %10.4f', YourTable.ConfidenceInt);
puts spaces in in the middle, both by the blanks and because the %10.4f format is larger than is needed for that data. Did you possibly change that code?

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

추가 답변 (1개)

Panos Ale
Panos Ale 2018년 1월 17일

0 개 추천

No, I just copied and pasted your code (changing of course the YourTable part). The blanks between the %10.4f do not effect the table format as I see after increasing or decreasing them. Is there another way(with code) to insert the blanks? May this problem be because I am using matlab 2015?

댓글 수: 3

Alternatively, in order to bypass the problem, I could just use your first code:
data = [num2cell(YourTable.AlpaParameter), cellstr(num2str(YourTable.ConfidenceInt))];
uitable(...', 'Data', data)
and place the data in column 1 to the left side of the grid. Is it possible?
Walter Roberson
Walter Roberson 2018년 1월 17일
Very odd... The spacing does show up if the ColumnWidth has been left 'auto' and you have not changed the width by attempting to drag it. Unfortunately in that combination, the second column is cut off because 'auto' is not wide enough to hold all of the information. As soon as you change the width of the second column, the spacing disappears!
I do not understand at the moment why this is happening. It will require more exploration.
Panos Ale
Panos Ale 2018년 1월 17일
Anyway! Thank you very much for your concern , all your respones were very helpful!

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

카테고리

도움말 센터File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

질문:

2018년 1월 16일

댓글:

2018년 1월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by