Question: MATLAB Create the vector [1 2 3 4]. Open a binary file for writing, then write the vector as uint8 values to the file. Close
MATLAB
Create the vector [1 2 3 4]. Open a binary file for writing, then write the vector as uint8 values to the file. Close the file. Use the MATLAB function dir to determine the number of bytes in the file. Display the number of bytes. Open the binary file for reading, then read (and display) all four uint8 values. Next, you should read the binary file again, but this time use the precision ubit1. In this way, MATLAB will see the data as a collection of bits (rather than bytes). But first, you must rewind the file to the beginning; you can do this with the command: frewind(fid) where fid is the file identifier. Use a for-loop. Each time through the for-loop, you will read a vector of 8 bits (that is, 8 values each with precision ubit1) and then print the 8 bits on a horizontal line. Taking into consideration that the numbers were stored little-endian in the file, you should be able to verify that the bit patterns represent the original data.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
