필터 지우기
필터 지우기

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 CenterFile Exchange에서 Tables에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by