How can I remove the ranges from a specific column vector?
2 views (last 30 days)
Show older comments
Hello;
How can I remove the following ranges from the k column vector below:
k=[1 0 2 1 9 8 0 0 4 2 3 3 5 1 1 0 3 2].' ;
ranges to be removed from k column vector are as;
range1=k(1:4); range1=k(9:12); range1=k(13:16);
Thanks in advance!!
0 Comments
Accepted Answer
Stephen23
on 28 Mar 2018
Edited: Stephen23
on 28 Mar 2018
>> vec = [1;0;2;1;9;8;0;0;4;2;3;3;5;1;1;0;3;2;0;0;0;0;0;0];
>> tmp = reshape(vec,12,[])
tmp =
1 5
0 1
2 1
1 0
9 3
8 2
0 0
0 0
4 0
2 0
3 0
3 0
>> tmp(1:4,:) = []
tmp =
9 3
8 2
0 0
0 0
4 0
2 0
3 0
3 0
>> tmp(:)
ans =
9
8
0
0
4
2
3
3
3
2
0
0
0
0
0
0
2 Comments
David Fletcher
on 28 Mar 2018
Neat. Easily beats my solution.
a=1:4
b=0:12:N;
c=a+repmat(b,4,1)';
del=reshape(c',1,numel(c))
k(del)=[]
More Answers (1)
See Also
Categories
Find more on Logical 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!