Azzera filtri
Azzera filtri

how can I convert negative signed floating values into binary ?

1 visualizzazione (ultimi 30 giorni)
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 Commenti
Walter Roberson
Walter Roberson il 29 Ott 2018
Subtract '0' from the output of dec2bin. Also be sure to specify width 8 for dec2bin.
Sarfaraz Ahmed
Sarfaraz Ahmed il 29 Ott 2018
Modificato: Sarfaraz Ahmed il 29 Ott 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

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Characters and Strings in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by