convert logical values to numeric values
84 次查看(过去 30 天)
显示 更早的评论
Hi Everyone,
Really simple question but I'm struggling converting a logical array from an ischange function to a double matix. I've written the following code just to show the issue I am having. How do I convert the b to a double matrix?
Thanks!
a=[1 1 5 1 1]
b = ischange(a)
c = cell2mat(b)
0 个评论
采纳的回答
更多回答(1 个)
Steven Lord
2021-3-2
What do you want the double array to represent?
- Just 0 and 1 instead on false and true? Use Jan's approach.
- 0 where there isn't a change point, the value of the original signal where there is? Use .* to multiply the original signal and the logical vector.
- The indices where the change points occur in the original signal? You can use find for this, but if you're planning to use this for indexing (to get just the change point value) you can use the logical array returned by ischange to perform logical indexing.
- Something else, in which case please explain what you want to do in more detail.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!