Take 102 Elements Equally Spaced of an Existing Array

15 views (last 30 days)
Hello,
I have an array Fold_Angle_Unsteady_100_Filtered (991x1) and I would like to take 102 elements equally spaced from it, how can I do it? I know I can do something like Fold_Angle_Unsteady_100_Filtered(1:10:end), but then my vector will be 100x1 and not 102x1. Is there a way to solve this issue?
I will then use this method also to other arrays of similar dimensions to find again other sub-arrays of 102x1, for this reason I would like to find a roboust method.
Thanks

Accepted Answer

Adam Danz
Adam Danz on 1 Jul 2022
Edited: Adam Danz on 1 Jul 2022
> Is there a way to solve this issue?
No. 991 is not divisible by 102.
The following is a 102 vector starting with 1 and ending with 991. Note that these are not integer values so they cannot be used to index the 991 element vector.
y = 1 : 990/101 : 991
y = 1×102
1.0000 10.8020 20.6040 30.4059 40.2079 50.0099 59.8119 69.6139 79.4158 89.2178 99.0198 108.8218 118.6238 128.4257 138.2277 148.0297 157.8317 167.6337 177.4356 187.2376 197.0396 206.8416 216.6436 226.4455 236.2475 246.0495 255.8515 265.6535 275.4554 285.2574
max(y)
ans = 991
size(y)
ans = 1×2
1 102
The closest you could do is round but then the intervals will not be uniform
yround = round(1 : 990/101 : 991)
yround = 1×102
1 11 21 30 40 50 60 70 79 89 99 109 119 128 138 148 158 168 177 187 197 207 217 226 236 246 256 266 275 285
diff(yround)
ans = 1×101
10 10 9 10 10 10 10 9 10 10 10 10 9 10 10 10 10 9 10 10 10 10 9 10 10 10 10 9 10 10
Depending on what you're doing, you might be able to interpolate and resample.

More Answers (0)

Tags

Products

Community Treasure Hunt

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

Start Hunting!