Why is my signal builder not giving precise outputs?
Show older comments
I have a signal builder block with the following signal:

I connect my signal builder block to a "To Workspace" block.

I am using a fixed step solver with sample time of 0.05s. Hence, the output variable "simout" should contain the values of the signal at every Peak and Trough, that is, it should only contain 0's and 1's.
However, at certain time steps my output contains 0.999999999999999 instead of 1 and 1e-5 instead of 0.
Why is the output from my Signal Builder block not precise?
Accepted Answer
More Answers (1)
Naveen Venkata Krishnan
on 19 Dec 2019
This issue can be solved by using a signal editor block instead of signal builder block. The cause of the issue is because of interpolation and this option is not availbe in signal builder block.
Interestingly, it seems data from excel cannot be imported into signal editor block.
Hence we need to import data from excel into signal builder block convert it into signal editor block and uncheck interpolation in signal editor block. The below peice of code can be used to convert a signal builder block to signal editor block.
sbBlockH = [gcb]; % gcb is signal builder block path
seBlockH = signalBuilderToSignalEditor(sbBlockH,'Replace',true,'FileName','test2.mat');
Categories
Find more on Simulink 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!