How to implement the fwrite function as in C language?
Show older comments
Hi there, I want to know if it is possible to implement the fwrite function same as the C language fwrite.
To further explain my question let's say we have fwrite function in C which writes binary data into a file. The syntax of the function is as follow
fwrite(memory containing the data, number of bytes each item to be written, total number of items to write, destination file)
example
fwrite(iq_buff, 2, 2*2600000, signal.bin)
Now my question is how can we specify the number of bytes to be written during the fwrite function and how much data needs to be written in the file?
3 Comments
Rik
on 8 Apr 2022
Matlab will write the entire variable (although you have the option to skip bytes from the start). You will have to index your variable to skip trailing bytes.
The Matlab fwrite function does not provide the exact syntax you describe, but you should be able to write a wrapper that does. What did you try so far?
If all else fails, you can also use mex to actually use the C function.
Imtiaz nabi
on 8 Apr 2022
Imtiaz nabi
on 8 Apr 2022
Accepted Answer
More Answers (0)
Categories
Find more on Logical 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!