add column to matrix that allows to identify series
조회 수: 2 (최근 30일)
이전 댓글 표시
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
채택된 답변
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개)
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?
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!