Simulink vector to bit a second

2 views (last 30 days)
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 Comments
Anton Naymov
Anton Naymov on 5 Oct 2020
Yes. Function returns a vector.
Anton Naymov
Anton Naymov on 5 Oct 2020
Edited: Anton Naymov on 5 Oct 2020
I use matlab function block to generate vector, but I need to work with every bit from a vector(by one).

Sign in to comment.

Accepted Answer

Fangjun Jiang
Fangjun Jiang on 5 Oct 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 Comment
Walter Roberson
Walter Roberson on 5 Oct 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.

Sign in to comment.

More Answers (0)

Tags

Products

Community Treasure Hunt

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

Start Hunting!