How to delete value array and sum the residual value?

3 次查看(过去 30 天)
Hello, I have two array a=[5,6,7,3,4,1,4,3,1,4,8] and b=[4,1,1,5,3,6,1,2,3,3,1]. a is a value and b is the frequency of the value. I wanna delete the value that its frequency==1 and then the same residual value will be summed. I code something like this
d=[a;b]
for i = 1:length(d)
if (d(i,:) == 1)
d(i,:) = []
end
end
it doesn't work, ??? Index exceeds matrix dimensions. when the value is deleted should be like this [5,3,4,1,3,1,4 ; 4,5,3,6,2,3,3] and then the same residual value is summed should be [5,3,4,1 ; 4,7,6,9]. What shoud i do? Thanks in advance

回答(1 个)

Azzi Abdelmalek
Azzi Abdelmalek 2013-4-6
编辑:Azzi Abdelmalek 2013-4-6

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by