Filter löschen
Filter löschen

how can I convert negative signed floating values into binary ?

1 Ansicht (letzte 30 Tage)
Sarfaraz Ahmed
Sarfaraz Ahmed am 29 Okt. 2018
Bearbeitet: Sarfaraz Ahmed am 29 Okt. 2018
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 Kommentare
Walter Roberson
Walter Roberson am 29 Okt. 2018
Subtract '0' from the output of dec2bin. Also be sure to specify width 8 for dec2bin.
Sarfaraz Ahmed
Sarfaraz Ahmed am 29 Okt. 2018
Bearbeitet: Sarfaraz Ahmed am 29 Okt. 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

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Characters and Strings finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by