How can I split measured data in separate vectors, depending on sign value?
1 次查看(过去 30 天)
显示 更早的评论
Hello! Is it possible to split measured data f.e.v= [1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1] in separate vectors, f.e. only the 'growing' values: v1=[1 2 3 4 5], v2=[1 2 3 4 5].
Maybe with a find(sign(diff(v))==1) ?
Thank you!
0 个评论
采纳的回答
Star Strider
2022-3-7
One approach —
v= [1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1];
dv = gradient(v);
sel = v(dv>=0);
dsel = diff([1 find(diff([sel(1) sel])<0) numel(sel)+1]);
C = mat2cell(sel, size(sel,1), dsel)
v1 = C{1}
v2 = C{2}
.
2 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Multirate Signal Processing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!