How to generate random data with a specific data rate
조회 수: 7 (최근 30일)
이전 댓글 표시
Can anyone please tell how generate random data in MATLAB with a specific data rate?
Or a binary data stream with say sampling frequency of 20MHz?
댓글 수: 0
답변 (2개)
Walter Roberson
2011년 2월 14일
This question only makes sense in Simulink.
In Matlab, you cannot tell the difference between generating the random data at 20 MHz and consuming it as it generated, vs generating the random data at (say) 1 GHz for a burst and consuming it at 20 MHz until more samples are needed.
It is true, though, that in Matlab if you had a D/A interface and A/D interface, and the generated data had to include some feedback from the incoming signal, then the burst length of generating random samples would start to become important. In such a case, though, you would be better off having the data generation triggered by the callback of the data reception function rather than trying to fix a particular generation rate.
댓글 수: 0
Paulo Silva
2011년 2월 14일
endtime=1e-5; %when to stop the stream, careful with the value
%if you increase it the vector might use lots of memory
fs=20e6; %sampling frequency
t=0:1/fs:endtime; %generate the time vector
binstream=randi([0 1],1,numel(t)); %generate the random binary data
%stem(t,binstream) %represent the bits in a figure
%spy(binstream) %alternative way to represent the bits in a figure
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 C2000 Microcontroller Blockset에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!