Why is my Simulink data type randomly changing?
22 views (last 30 days)
Show older comments
Jonathan Scott
on 13 Mar 2023
Commented: Jonathan Scott
on 15 Mar 2023
I am having an issue with my Simulink simulation in that it is randomly changing from complex double at the output of one block to double at the input of the next, like so:
I really have no idea why this is happening, and it's causing Simulink to throw an error since the downstream code expects a complex double for the rest of the program. I am confused why it is changing type despite there being no block there?
If this helps debugging, I had this code running perfectly fine before I decided to implement a switch/case -> merge before the square root filter. Could there be some type of data type inheritance issue causing this? I have attempted to change the square root data type options but there doesn't seem to be anything that helps there.
0 Comments
Accepted Answer
Andy Bartlett
on 14 Mar 2023
Yes, this is most likely due to attribute propagation. You likely have an underspecified "chicken and egg loop" in your model. The connected blocks are happy to accept signal type of real or complex and don't initially specify a choice. Simulink is likely breaking the "chicken and egg loop" by heuristically forcing one of the blocks to make a choice.
Your old model either didn't have the "chicken and egg loop" or the heuristics happened to lead to a happy agreement. In your new model, the heuristic rules aren't good enough.
That's my theory anyway.
To break the "chicken and egg loop", I suggest you drop in one or more Signal Specification blocks. Go to the last block parameter "Signal Type" and set it to "complex." Drop that block onto a signal wire that you definitely want to be complex, but currently is producing a real vs complex error.
More Answers (0)
See Also
Categories
Find more on Array and Matrix Mathematics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!