how can I convert negative signed floating values into binary ?

3 views (last 30 days)
Hi. I designed ADC in simulink and now I want to convert final scalar values into binary (digital form). how can I convert these values into binary ? The values are like that : 1) -0.5 2)-30.5 3)-62.5 4)43.5 5)37.5
If i remove this fraction by doing this :
Dout=Dout+0.5; % Dout is final sampled scale value as I explained above
Dout_bin= dec2bin(typecast(int8(Dout),'uint8')); y = Dout_bin; then it shows an error how can I remove this error as well ?
Data 'y': Character outputs are not supported in Simulink and Stateflow. Cast 'y' to int8 or uint8 instead. Fix the indicated errors, or explicitly specify sizes and/or types for all block outputs.
is there any way in either script form or in simulink ? I attached my design. kindly help me in this regard.
Thanks
  2 Comments
Walter Roberson
Walter Roberson on 29 Oct 2018
Subtract '0' from the output of dec2bin. Also be sure to specify width 8 for dec2bin.
Sarfaraz Ahmed
Sarfaraz Ahmed on 29 Oct 2018
Edited: Sarfaraz Ahmed on 29 Oct 2018
Yes Sir, I found it . I was wrongly typing '0'. Thank you Sir.
can't I use Integer to bit converter block here ? I tried but it shows an error that " Error in port widths or dimensions. Output port 1 of 'ADC_ch2_DM/ADC1 ' is a matrix with a maximum size of [1x10000]
How can this error be fixed? I attach the design.
Thanks

Sign in to comment.

Answers (0)

Categories

Find more on Characters and Strings 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!