Rearranging rows using unique values in column
Mostrar comentarios más antiguos
If I have a matrix as follows: The first column is unique ID while the second column represents price:
x = [106 2;
106 4;
109 3;
109 7;
109 11;
106 3;
106 6;
109 16]
I want to arrange the matrix using the unique values in the first column to get the following:
x = [106 2;
106 4;
106 3;
106 6;
109 3;
109 7;
109 11;
109 16]
After arranging the matrix I want to calculate the change in prices for each unique ID to get the following
newdatawithchange = [106 2 --;
106 4 2;
106 3 -1;
106 6 3;
109 3 --;
109 7 4;
109 11 4;
109 16 5]
Then, how can I calculate the correlation between values in the second and third column but unique for each ID (There will be a coefficient for ID 106 and another coefficient for ID 109 with skipping the first row for each ID as there is no value for the change)
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!