Select numbers from an array under a specific condition
显示 更早的评论
Dear MATLAB Experts,
Hello. I was curious if I could request for an advice in constructing a program that does the following calculation.
I currently have an array A which contains random integers in numerical order. A = [1 2 4 5 7 9 11 12 13 14 18 23 26 28 32 33 36 37 38 40];
Starting from the first value of array A, I would like to select only the values from A where the selected values are spaced at least 4 numbers. That is, I would like to ultimately obtain A = [1 5 11 18 23 28 33 38] where the selected values from A are such that the numbers between have distances of at least 4.
I would greatly appreciate if you could provide me with any hints in programming this calculation. I am thinking of doing a while loop but having trouble where to start.
Thank you.
Sincerely,
Masato
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!