How to save data in a raw file?

조회 수: 20 (최근 30일)
joseba gonzalez
joseba gonzalez 2019년 2월 28일
댓글: Fady Samann 2020년 9월 7일
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
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?
joseba gonzalez
joseba gonzalez 2019년 2월 28일
Hi Bob,
First of all, thank you for answering.
Is an image file type where I have to use it to upload this data into a machine which only reads data in ".raw" file type. And yes it is a binary file, that is saved like an image.
I don´t know if I have explained myself correctly.

댓글을 달려면 로그인하십시오.

답변 (2개)

Namwon Kim
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
Namwon Kim 2020년 9월 7일
By default, 'fwrite' writes values from an array in column order as 8-bit unsigned integers.
Fady Samann
Fady Samann 2020년 9월 7일
thanks for the answer

댓글을 달려면 로그인하십시오.


Shane Gibbs
Shane Gibbs 2019년 2월 28일
I believe I found someone with the same issue as well.
Hope this helps!
  댓글 수: 2
joseba gonzalez
joseba gonzalez 2019년 2월 28일
Hi Shane,
Thank you for answering,
The main point is that I have the plot data saved in .txt file but I have problems when saving this data in .raw file type...
Bob Thompson
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 CenterFile Exchange에서 Large Files and Big Data에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by