Matrix creation which identify link of vehicles
2 次查看(过去 30 天)
显示 更早的评论
Hello.
I've a matrix 61312*3.
1st column: from 1 to 81 (Origin place of a vehicle) 2nd column: from 1 to 81 (Destination place of a vehicle) 3rd column: from 1 to 246 (where the vehicle has surveyed)
There are 61312 observation (no. of rows) at 246 locations.
I need to create a matrix which shows that from origin (1 to 81) to Destination (1 to 81) which location (1 to 246) these vehicle follow. I think the order of the matrix will be 81*81.
Kindly let me know how should I proceed. thanks in advance.
采纳的回答
Andrei Bobrov
2014-7-4
编辑:Andrei Bobrov
2014-7-4
[a,~,ii] = unique(A(:,2));
[b,~,jj] = unique(A(:,3));
out1 = accumarray([ii,jj],A(:,1),[max(ii), max(jj)],@(x){x});
out = [[{nan};num2cell(a(:))],[num2cell(b(:)');out1]];
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Phased Array Design and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!