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 件のコメント

Fangjun Jiang
Fangjun Jiang 2020 年 10 月 5 日
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 2020 年 10 月 5 日
Yes. Function returns a vector.
Anton Naymov
Anton Naymov 2020 年 10 月 5 日
編集済み: Anton Naymov 2020 年 10 月 5 日
I use matlab function block to generate vector, but I need to work with every bit from a vector(by one).

サインインしてコメントする。

 採用された回答

Fangjun Jiang
Fangjun Jiang 2020 年 10 月 5 日

0 投票

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 件のコメント

Walter Roberson
Walter Roberson 2020 年 10 月 5 日
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.

サインインしてコメントする。

その他の回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by