フィルターのクリア

Align table data to the left

7 ビュー (過去 30 日間)
Asi
Asi 2023 年 10 月 15 日
回答済み: Walter Roberson 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 Center および File ExchangeTables についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by