reading a binary file as a timeseries

1 view (last 30 days)
I want to load the data of a binary file, that is, the ones and zeros, into a vector or preferably a time series, so that I can take it through a from workspace block into simulink as a signal (pulses at the ones). Is this possible? And if it is, then can anyone suggest how?

Accepted Answer

Walter Roberson
Walter Roberson on 6 Oct 2015
You can fopen() the file, fread() it with the appropriate "precision" information, and fclose() afterwards. If the data is packed with multiple bits per byte you might need to use de2bi or dec2bin or bitget to extract the individual bits. Once you have everything extracted you can use it with a From Workspace block.
Note: From Workspace blocks extract the data from the workspace of the calling routine if you call sim() directly to run the model. If you start the model from the GUI then From Workspace will look for the data in the "base" workspace; you can put it there using assignin('base')

More Answers (0)

Categories

Find more on Prepare Model Inputs and Outputs in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!