how to convert cell 10X8 to mattrix and matrix 10X8 to to 8 bit value [1,1,1,1,0,0,0,0]

1 vue (au cours des 30 derniers jours)
Fs=10;
Ts=1/Fs;
L=10;
t=(0:L-1)*Ts;
% ms1=sin(2*pi*50*t);
% ms2=cos(2*pi*50*t);
ms1=sawtooth(2*pi*50*t);
%% analog to digital
no_of_bit=8;
q_level=50/(2^(no_of_bit)-1);
msg1_abs=abs(ms1);
msg_0=fix(msg1_abs/q_level);
digit_ms1=dec2bin(msg_0,no_of_bit);
v=cell2mat([{digit_ms1(:,:,:)}]);
v1=str2num(v); %%%% THIS is giving coulm bits but I want 8 bit data in bit format to used it as 8 bit i.e [1,1,1,1,0,0,0,0]
  1 commentaire
Walter Roberson
Walter Roberson le 8 Jan 2019
just take the result of dec2bin and subtract '0' which is the character for the digit 0.

Connectez-vous pour commenter.

Réponse acceptée

Luna
Luna le 8 Jan 2019
Hi,
Just try this:
v = logical(digit_ms1 - '0'); % if you want bits logical use logical otherwise it will give you double array
  3 commentaires
Bablu Singh
Bablu Singh le 17 Jan 2019
helo sir
I need to recover ms1 sawtooth back from V %% ms1=sawtooth(2*pi*50*t);
i.e digital to sawtooth
plz help

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Numeric Types dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by