How to display a Table in LiveScript just the same way it is displayed upon defining it or calling it directly?
115 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
Walter Roberson
2022 年 10 月 31 日
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
2022 年 11 月 4 日
編集済み: Yogesh R
2022 年 11 月 4 日

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
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Environment and Settings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!