I have a question related to another one recently asked. I download my data as a csv.file
. I then format it in MATLAB. I obtan formatted data such as:
I would like to format the data so that I obtain:
In other words, the date should be in the first column, while the two identifier should be in the first two rows, respectively.
I tried the code provided by @gnovice, yet I have problems to adjust for the second identifier. The code is:
A = accumarray([rowIndex colIndex], data(:, 4), [], @(x) x(1));
A = [NaN colVals; rowVals A];
where data
is equal to picture (1).
Therefore, I obtain a matrix A
like:
A =
NaN 1 2 3;
20160101 100 80 90;
20170101 150 90 200;
How can I adjust my code in a way that the second identifier is taken care of and A
becomes:
A =
NaN 1 2 3;
NaN 10 10 15;
20160101 100 80 90;
20170101 150 90 200;