- 11 observations of two variables (x and y), where each value is scalar
- 1 observation of two variables (x and y), where each value is a length-11 vector
- 2 observations of 11 variables (unnamed), where each value is a scalar (and these observations are named "x" and "y")
- 2 observations of a single variable (unnamed), where each value is a length-11 vector (and these observations are name "x" and "y")
- something else?
Table setup to rearrange where titles are
1 回表示 (過去 30 日間)
古いコメントを表示
I am struggling to get my table to look the way I want it to, I want the titles to be on the left instead of on top of my table.
x=0:1:10;
y=[10,12,15,19,23,25,27,32,34,36,41];
table(x,y)
I wish to get it so the inputs of x are on top of the inputs of y
1 件のコメント
the cyclist
2024 年 11 月 24 日
Before suggesting a way of displaying your data, we may need to understand how your data are structured -- and what they represent.
The norm (not just in MATLAB) is that columns list variables, and rows list observations. Each entry in the table is the value of that variable, for that observation.
It is unclear to me, from what you have posted, the structure of your data. Which is these do you have?
Note that @Animesh's solution implicitly assumes the third option (or possibly the first option, but just showing the table transposed from the norm).
It is very difficult (at least for me) to suggest a solution without understanding the data structure.
回答 (1 件)
Animesh
2024 年 11 月 24 日
To create a table with titles on the left instead of on top, you can use MATLAB's table functionality and transpose the data.
You can try something like this:
T = table(x', y', 'VariableNames', {'x', 'y'});
% Transpose the table to have titles on the left
T_transposed = array2table([T.x, T.y]', 'RowNames', {'x', 'y'});
disp(T_transposed);
Here, "x" and "y" are first made into a table with the "table" function, and then it's transposed using "array2table" to switch the rows and columns, with "RowNames" used to label the rows.
You can refer the following MathWorks documentation for more information on "array2table":
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Tables についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!