Sample evenly-ish vector of unevenly distributed indices

4 次查看(过去 30 天)
Say I have a vector of indices
v = [v1 v2 v3 v4 v5] = [1 34 456 1345 4567]
I try to find a way to sample v in an evenly-ish way while keepking these points. Is there a quick way to do that instead of a loop over every range between two points [v_i v_j], I have numerous and long vectors...
  4 个评论
Voss
Voss 2021-12-10
How about this:
vnew = min(v):max(v);
Now, as long as v contains only integer values, all elements of v are in vnew. And diff(vnew) is all 1s, so the difference is as constant as it can get.
Does that work?
Ouatehaouks
Ouatehaouks 2021-12-10
Thanks for your answer. The thing is that the indices can be very large, so I want to refine v but not down to delta=1.

请先登录,再进行评论。

采纳的回答

Matt J
Matt J 2021-12-10
编辑:Matt J 2021-12-10
Perhaps as follows,
vnew = union( min(v):delta:max(v) ,v);
  6 个评论
Ouatehaouks
Ouatehaouks 2021-12-10
Sorry I don't know how to accept the correct answer which is in your last comment.
Matt J
Matt J 2021-12-10
编辑:Matt J 2021-12-10
No problem. Our whole chain of comments is considered part of the "Answer".

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by