Filter löschen
Filter löschen

Creating table with variable and row names

160 Ansichten (letzte 30 Tage)
Mathias Heuser
Mathias Heuser am 3 Jan. 2020
Kommentiert: Mathias Heuser am 3 Jan. 2020
Hi,
I am having problems with creating a output table, which for some reason work when i only use one variable, but not when i enter a second one. Code:
mean_rgoog = mean(rgoog);
mean_rm = mean(rm);
std_rgoog = std(rgoog);
std_rm = std(rm);
disp(table(mean_rgoog, mean_rm, 'VariableNames', {'mean'}, 'RowNames', ...
{'mean_rgoog', 'mean_rm'}));
Again, it works if i remove the 'mean_rm' from the 'RowNames'. Anybody knows how to fix this, to make it work with multiple rows?
  1 Kommentar
Adam Danz
Adam Danz am 3 Jan. 2020
In the future, provide the entire error message - it gives us very big hints at what the problem is ;)

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Adam Danz
Adam Danz am 3 Jan. 2020
You're likely getting an error,
Error using table
The RowNames property must contain one name for each row in the table.
It appears you're trying to create a table with 1 column and 2 rows but instead, your table() inputs provide two columns of 1 row of data. Instead, vertically concatenate the two rows of data into 1 column.
table([mean_rgoog; mean_rm], 'VariableNames', {'mean'}, 'RowNames', {'mean_rgoog', 'mean_rm'})
  1 Kommentar
Mathias Heuser
Mathias Heuser am 3 Jan. 2020
This worked (makes total sense), i will remember the error in the future - thank you!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Tables finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by