add column to matrix that allows to identify series
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Locks
el 15 de Sept. de 2014
Comentada: Locks
el 16 de Sept. de 2014
Hi,
I have the following problem:
I constructed a matrix from several timeseries and I need to add a column to the matrix with the identifier of the respective series. Here an example:
series1=[1 1000; 2 990]
series2=[1 750; 2 780]
series3=[1 1250; 3 1150]
seriesCompl=[series1; series2; series3]
what I need in addition is now a column in matrix seriesCompl where I can see which series it is.
The outcome should look like
1 1000 series1
2 990 series1
1 750 series2
2 780 series2
1 1250 series3
3 1150 series3
0 comentarios
Respuesta aceptada
Roger Wohlwend
el 16 de Sept. de 2014
If you want to combine numbers and texts in a matrix you have to create a cell matrix, a dataset or a table. However, I am not sure I you really want to do that. The solution to your problem depends on what you want to do with the matrix seriesCompl. If you want to perform calcualtions or plot the data in the matrix, then it would be wise to keep the matrix numerical. Instead of writing a name in the third column you could use numbers: series1 = 1, series2 = 2, series3 = 3, ... If you have other plans, then you have to choose a different data type for your matrix (cell, dataset or table).
Más respuestas (1)
Adam
el 16 de Sept. de 2014
As you have it there 'series1', etc are just variable names. I would assume you are not planning on keeping all the individual variables around as well as the combined matrix so since the variable name is not really relevant to store along with the data could you not just add a numeric column of 1, 2 or 3 for which series each row belongs to?
0 comentarios
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!