# add column to matrix that allows to identify series

3 ビュー (過去 30 日間)
Locks 2014 年 9 月 15 日
コメント済み: Locks 2014 年 9 月 16 日
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

サインインしてコメントする。

### 採用された回答

Roger Wohlwend 2014 年 9 月 16 日
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).
##### 1 件のコメント表示非表示 なし
Locks 2014 年 9 月 16 日
I will use a number as unique identifier for the series, thanks a lot

サインインしてコメントする。

### その他の回答 (1 件)

Adam 2014 年 9 月 16 日
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?

サインインしてコメントする。

### Community Treasure Hunt

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

Start Hunting!

Translated by