How to delete value array and sum the residual value?

1 view (last 30 days)
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

Answers (1)

Azzi Abdelmalek
Azzi Abdelmalek on 6 Apr 2013
Edited: Azzi Abdelmalek on 6 Apr 2013
a(b==1)=[];

Categories

Find more on Multidimensional Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!