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개)

카테고리

태그

질문:

2020년 10월 5일

댓글:

2020년 10월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by