Split an array based on defining a limit for the first value (left edge)
1 次查看(过去 30 天)
显示 更早的评论
Hi all,
I have data for wind speed as shown in the image. The points of interest is when the data first hits 20, and from here, all points are recorded and stored in anh array until the data hits 30. All occasions where this trend occures are stored as seperate arrays within a cellarray. However, i am noticing that some of the arrays have incorrectly stored data. For example, "Array 2" incorrectly uses where the data first decreases below 30 as the first value, and then correctly records the final value where data next hits 30m/s. However, i want the first point of "Array 2" to start where data first reaches 20. The corrected version of Array 2 is visualised in orange.
Is there any way of defining a limit for the first value of all arrays generated? Such as for Array 2, i would like a code to read all data points in the array from left to right, and remove values so that the first value of the array becomes roughly 20 m/s (plus or minus 2 m/s).
Thanks very much !
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/795989/image.png)
0 个评论
回答(1 个)
KSSV
2021-11-10
You check the initial time value and final time value of the array. If they are not like what you wanted, you can do interpolation and get the values at the required dates. Read about interp1.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Cell Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!