Align table data to the left

7 次查看(过去 30 天)
Asi
Asi 2023-10-15
Is there a way to align table data to the left?
Code:
clc;
clear all;
close all;
LastName = ["Sanchez";"Johnson";"Zhang";"Diaz";"Brown"];
Age = [38;43;38;40;49];
HeightPerson = [71;69;64;67;64];
Weight = [176;163;131;133;119];
patients = table(LastName,Age,HeightPerson,Weight)
  1 个评论
Dyuman Joshi
Dyuman Joshi 2023-10-15
I'm not sure if that can be done for table arrays. Any particular reason why you want to align the table data to the left?
It can be done for uitables though.

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2023-10-15
Yes.
You could copy all of the code having to do with implementing tables. Then modify it so that tables inherit from matlab.mixin.CustomDisplay . Then use the facilities described in https://www.mathworks.com/help/matlab/matlab_oop/custom-display-interface.html to customize the display of table entries
Be careful that you also track down all of the classes and functions that create table objects, including timetable2table() and regionprops(), and modify them to invoke your new table-equivalent class instead of the built-in table class instead.
I would suggest to you that it would be rather a lot easier to create your own displaytable() function that took at table and formatted it however you want. The difference would be that you would only get the desired output if you specifically requested it, instead of by default.
You could also investigate creating your own @tabular/display.m but I am not clear as to whether that would interfere with other uses of tables.

类别

Help CenterFile Exchange 中查找有关 Tables 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by