How to save structure as .asc?

5 Ansichten (letzte 30 Tage)
knoppyx
knoppyx am 24 Okt. 2017
Kommentiert: knoppyx am 25 Okt. 2017
Hello. I have a structure that looks like this:
And i whant to save these information in a .asc file. In the end the file will look like this:
I tried with printf but without results. Can you help me? I'm novice in Matlab.
Thanks
  3 Kommentare
knoppyx
knoppyx am 24 Okt. 2017
I tried:
fileID='blabla.asc';
fileID = fopen(fileID,'w');
fprintf(fileID,param.textdata,param.data);
fclose(fileID);
But the error is: Error using fprintf Invalid format.
Stephen23
Stephen23 am 24 Okt. 2017
@knoppyx: You have not specified any format string. Read the fprintf help to know how to specify the format string.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

KSSV
KSSV am 24 Okt. 2017
S{1} = 'IMC FAMOS' ;
S{2} = 'NAME: Wheelspeed_R_L' ;
S{3} = 'Time: 18/08/16 11:28:46' ;
S{4} = 'Length: 21456' ;
S{5} = 'unit X-Axis: 1 Samples' ;
S{6} = '1st x-Value: 0.0089 samples' ;
S{7} = 'unit Y-Axis: rpm' ;
data = rand(21456,2) ; % some random data
fid = fopen('myfile.asc','w') ;
for i = 1:length(S)
fprintf(fid,'%s\n',S{i}) ;
end
fprintf(fid,'%s\n','Data:') ;
fprintf(fid,'%f %f\n',data) ;
fclose(fid) ;
  8 Kommentare
Stephen23
Stephen23 am 25 Okt. 2017
Bearbeitet: Stephen23 am 25 Okt. 2017
@knoppyx: one day ago I wrote that you should "Read the fprintf help to know how to specify the format string." Have you read the documentation to learn how to specify different format strings?
You will need to transpose the input matrix, and specify format that suits your needs. Something like this:
fprintf(fileID,'%.4f%11.4f\n',param.data.');
You need to read the fprintf documentation carefully, because there are lots of options for specifying the format string.
knoppyx
knoppyx am 25 Okt. 2017
i've solved it, thank you. You were right, i've solved it with the help of transpose.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by