How can I make an object declared within a function persistent?
3 次查看(过去 30 天)
显示 更早的评论
I have defined two handle classes for audio filters (LPcomb and APfilt). I would like to write a function to apply these filters to streaming audio on a block-by-block basis. So I declare the object variables to be persistent. In the "if isempty - end" block I try to instantiate these variables as objects of my classes. I get the following error message:
The following error occurred
converting from LPcomb to double:
Error using double
Conversion to double from LPcomb
is not possible.
So it seems that when you declare a variable to be persistent, it is declared as a double and cannot be instantiated as an object. How can I declare persistent objects in a function?
1 个评论
Guillaume
2015-6-16
I cannot reproduce the problem. Can you post the code that is creating the error?
采纳的回答
Eric Lin
2015-6-17
As Guillaume notes, we'll need the code in question to help you further.
However, it is important to note that persistent variables are initialized as double arrays so a type change must first be performed if you would like the persistent variable to store non-double elements, as discussed in this answer: Trouble with persistent array of class objects
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Code Generation and Deployment 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!