table editing and excel export

1 visualización (últimos 30 días)
Ceshi
Ceshi el 20 de Nov. de 2019
Comentada: dpb el 22 de Nov. de 2019
Hello,
I don't know Matlab well yet and can't get any further.
I get from an analysis of a Matlab program the results as a table, which I want to edit in Matlab and export to Excel.
Time Value1 Value2 ...
1.0 27832.2 129819.2 ....
... ...
After the first line, I would now like to insert 2 more lines. One line should contain the unit and the second line should contain a comment (2 of the test parameters).
In addition, a variable is to be added after each heading ( Value1 - Sample1, Value2 - Sample1...).
The table is then to be exported into an Excel table. The name should consist of the experiment data ( Sample1_date.xls). The two variables are read in at the beginning of the program.
Then a second Excel table is to be exported in which the data of the Value1-Value10 columns are converted with a conversion factor.
Can anyone help me?
Sorry for my bad english, I hope it's understandable.
  3 comentarios
Ceshi
Ceshi el 22 de Nov. de 2019
Editada: dpb el 22 de Nov. de 2019
Okay so the export itself with writetable is no problem.
But I don't get it to insert 2 rows into my table.
My result table contains numbers and I want to insert a line with the units and a line with a comment in front of it.
e.g.
unit = {'kg' 'm' 's'..}
If I try like this:
concatenatedtable = [unit; resulttable];
I get the error message
Cannot concatenate the table variable 'xyz' because it is a cell in one table and
a non-cell in another.
dpb
dpb el 22 de Nov. de 2019
Ayup. No can do that. MATLAB table variables are like regular variables--they must be consistent in type. The only way you can write numeric data together with non is to use a cell array to hold the content. That then will probably make using your resulting table difficult unless this is solely for display purposes.
Tell/Show us what you're really trying to accomplish as an end result and probably be able to get some better approaches.

Iniciar sesión para comentar.

Respuestas (1)

Image Analyst
Image Analyst el 22 de Nov. de 2019
I suggest you add the units in the column headers themselves, like
variableNames = {'Time_[sec]', 'Value1_Sample1_[kg]'};
  1 comentario
dpb
dpb el 22 de Nov. de 2019
There actually is a 'VariableUnits' property in the table object for exactly that purpose. As well as 'VariableDescriptions' and 'UserData' for additional identification.
It's unfortunate that the command window display of a table doesn't have a way to cause these to show up, though, you have to query their values (at least thru R2017b which is latest I've gotten around to installing here).

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by