How to display a Table in LiveScript just the same way it is displayed upon defining it or calling it directly?
128 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I'm working with tables in MATLAB LiveScript (.mlx files).
Mehtod 1. If I define a table (here: patients) and leave the semi-colon off, it shows a beautiful table in LiveScript. (and not in vanilla MATLAB, where the output will be just as in Method 3)
Method 2. If I 'call' a previously-defined table (again, patients), I get a warning that simply calling a variable is not the ideal practice and I should instead use disp for the same.
Method 3. But when I use disp to call a table, it does not show the table in the same way as in Method 1.
How do I display a previously-defined table in the same way as Method 1, without getting a warning like in Method 2?
LastName = ["Sanchez";"Johnson";"Zhang";"Diaz";"Brown"];
Age = [38;43;38;40;49];
Smoker = [true;false;true;false;true];
patients = table(LastName,Age,Smoker) %Method 1 example
%shows a beautiful 'table-like' table whose individual 'cells' can be
%selected, which also highlight the corresponding row (instance) and column
%(variable). Only applicable to Live Script. Else the output is the same as
%Method 3.
disp(patients) %Method 3 example
%disp command shows a not so pretty, but seemingly terminal friendly table.
2 Commenti
Walter Roberson
il 31 Ott 2022
The case of assignment without semicolon is invoking @tabular/display if I recall correctly. Which is the same function as just listing the variable name. The difference is that the editor creates a warning (not error) if you do not use disp(). The editor will also warn if you call display() yourself.
The above is not intended to be a solution, just more detail about what is happening.
Yogesh R
il 4 Nov 2022
Modificato: Yogesh R
il 4 Nov 2022
I am not getting any warning for simply calling the variable patients, even after enabling all warnings. I am not sure why you are getting it.
Anyways can you try using display instead of disp, and check if you are getting any warning.
P.S: Code was ran on MATLAB R2022b
Risposte (0)
Vedere anche
Categorie
Scopri di più su Environment and Settings in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!