Generating binary numbers from signal

Hello
I would like to generate a sequence of binary numbers(16 bit).
I can get the variable from this:
Bit it is a variable in double precision, and the sample rate is too high. I would like to get a signal like this as in the attatched picture, but with 16 samples per period, so about 36 oscillations and 576 samples, time information I don't need.
For example this is a single period of a sine wave:
1000000000000000
1011000011111011
1101101010000010
1111011001000001
1111111111111111
1111011001000001
1101101010000010
1011000011111011
1000000000000000
0100111100000100
0010010101111101
0000100110111110
0000000000000000
0000100110111110
0010010111010111
0100111100000100
I would like to get something like this but for the attatched image.
Can I downsample the variable and export it as binary numbers somehow?
Thanks in advance...

 Respuesta aceptada

darova
darova el 16 de Ag. de 2019
Editada: darova el 16 de Ag. de 2019
Just changed an example from link you gave
clc,clear
fnx = @(x,fn) sin(2*pi*fn*x).*exp(-fn*abs(x));
t = linspace(0,1.2,576); % less points
d = 0:1/5:1; % periods?
dd = [d;4.^-d]';
y = pulstran(t,dd,fnx,30);
plot(t,y)
xlabel('Time (s)')
ylabel('Waveform')
y1 = y-min(y); % make minimum 0
y1 = y1/max(y1)*65353; % make maximum 65353
% dec2bin(y1) % convert to binary

1 comentario

Mark Wolf
Mark Wolf el 16 de Ag. de 2019
Thanks,
especially the preparation for dec2bin helps alot. Now I am getting the right binary values.

Iniciar sesión para comentar.

Más respuestas (0)

Preguntada:

el 16 de Ag. de 2019

Comentada:

el 16 de Ag. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by