Rearranging rows using unique values in column
显示 更早的评论
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)
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!