Filter löschen
Filter löschen

Align table data to the left

7 Ansichten (letzte 30 Tage)
Asi
Asi am 15 Okt. 2023
Beantwortet: Walter Roberson am 15 Okt. 2023
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 Kommentar
Dyuman Joshi
Dyuman Joshi am 15 Okt. 2023
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.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Walter Roberson
Walter Roberson am 15 Okt. 2023
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.

Kategorien

Mehr zu Tables finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by