Info
此问题已关闭。 请重新打开它进行编辑或回答。
Center of repeatative/duplicate values in Matlab
1 次查看(过去 30 天)
显示 更早的评论
Hi,
I have a vector lik A = [1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 3 3 ]. I want to get index of centre and its value fo this vector. How can i do that In matlab scirpt ?
The solution of above problem should be.
values = [1 2 3];
Centre_Index = [3 8 14 ];
Thanks in adavnce .
0 个评论
回答(2 个)
Ameer Hamza
2020-3-14
x = [1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 3 3 ];
indexes = [1 find(x(2:end) - x(1:end-1))+1 numel(x)];
indexes = floor(movmean(indexes, 2, 'Endpoints', 'discard'));
0 个评论
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!