How to save data in a raw file?
45 次查看(过去 30 天)
显示 更早的评论
Hi,
I am quite new in MAtlab and I would like to have some help,
I have a sine with amplitude and time and I want to save the amplitude data into a raw file. How can I get it? I have tried with the code above.
I am not sure if it is correct. So I would like to know if it is correct or in other way, how can I do it in a correct way. Thank you in advance.
fid=fopen('Profilevoltage.raw','w');
fwrite(fid,amplitude,'uint16');
fclose(fid);
2 个评论
Bob Thompson
2019-2-28
What do you mean by 'raw' file? Is that an actual file type, or are you meaning a basic ascii or binary file?
回答(2 个)
Namwon Kim
2019-10-21
Your code,
fid=fopen('Profilevoltage.raw','w');
fwrite(fid,amplitude,'uint16');
fclose(fid);
I recommend that you try those codes.
Use a matrix transpose
fid=fopen('Profilevoltage.raw','w+');
fwrite(fid,amplitude','uint16');
fclose(fid);
3 个评论
Namwon Kim
2020-9-7
By default, 'fwrite' writes values from an array in column order as 8-bit unsigned integers.
Shane Gibbs
2019-2-28
I believe I found someone with the same issue as well.
Hope this helps!
2 个评论
Bob Thompson
2019-2-28
If the data is being saved in a binary format, then you can just label the file as '.raw' rather than '.txt'. You do need to make sure you are saving it in a binary compatible file format first though.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Low-Level File I/O 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!