Simulink vector to bit a second

I have a vector [1, 1023]. To exampe: [1, 0, 1 ... 0], but I want to send only one bit a second from vector in simulink. How I can do that? I want to pass the number to another block and so on 1023 times.

3 comentarios

Fangjun Jiang
Fangjun Jiang el 5 de Oct. de 2020
You mean a vector like [1, 0, 1 ... 0], every value is either 0 or 1, the total length is 1023?
Anton Naymov
Anton Naymov el 5 de Oct. de 2020
Yes. Function returns a vector.
Anton Naymov
Anton Naymov el 5 de Oct. de 2020
Editada: Anton Naymov el 5 de Oct. de 2020
I use matlab function block to generate vector, but I need to work with every bit from a vector(by one).

Iniciar sesión para comentar.

 Respuesta aceptada

Fangjun Jiang
Fangjun Jiang el 5 de Oct. de 2020
If you want to feed a vector like [1, 0, 1 ... 0], in which every value is either 0 or 1, the total length is 1023, at a rate of one value per second, then first form the data
data=[1,0,1, 0,1,0,0];
time=[0:numel(data)-1];
Then use the FromWorkspace block and specify the data as [time(:), data(:)].
This will feed the data as desired.
If your data is generated by a MATLAB Function block, you need to keep in mind that the MATLAB Function block is executed at every simulation step. Is the 1023-value data generated at once during one simulation step, or is the data generated one-value-at-a-time?
If the data is generated at once, it is better to generate the data separately and use the FormWorkspace block to import the data.
If the data is generated one-value-at-a-time, then your question is moot.

1 comentario

Walter Roberson
Walter Roberson el 5 de Oct. de 2020
If the vector is generated all at once, you can use a DSP block to buffer it from the original size to one sample per frame. However, that has the effect of speeding up the sample rate, as Simulink expects that at the next time it runs the vector production block that there will be a full vector available again.

Iniciar sesión para comentar.

Más respuestas (0)

Productos

Etiquetas

Preguntada:

el 5 de Oct. de 2020

Comentada:

el 5 de Oct. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by