11-18-2021 09:10 AM
I might find later that I'm missing something very simple here, but so far I am perplexed.
I have a typedef which is a cluster of double. The cluster of double must return all NaN values as a default.
If I wire out the type definition through the indexing tunnel on a for loop, the resulting wire returns all zeros rather than NaN.
This is a problem because the program I'm trying to make can return 0 as a valid value; I use NaN to denote that no valid values were returned. See the screenshot where indexing the resulting array gives a cluster of all zeros. Sample code is also attached. This should be a pretty easy task; I know I've done this on multiple occasions and had several programs that relied on this behavior. I think I broke something?
Solved! Go to Solution.
11-18-2021 11:04 AM
The arrays output from the loop contain neither NaNs nor zeros, they are empty.
Your subarray shows zeros because the elements have 0 as their default value.
Default values do not propagate from typedefs to existing instances.
However when you create a new instance, it will inherit the default value from the typedef.
11-18-2021 11:13 AM
My receiving indicator is of the same typedef, which has my expected default set. Based on your final statement, shouldn't the resulting empty array still show the expected defaults?
11-18-2021 11:24 AM
@AllisonSCJ wrote:
My receiving indicator is of the same typedef, which has my expected default set. Based on your final statement, shouldn't the resulting empty array still show the expected defaults?
No. Reread what I wrote.
11-18-2021 12:45 PM
Consider making your type definition into a class instead.
With classes, the default value is part of the type and any changes to that will apply to all areas where default values are created.
With type definitions, the default value you put in the control is what will appear when you do things like put a new version of it onto a front panel or block diagram, but any changes to defaults will not propagate to existing controls or constants, and they will never apply in certain situations (like exiting a case or event structure with the "use default value if unwired" option enabled).