필터 지우기
필터 지우기

How to write part of a structure to an output file (.txt)?

조회 수: 1 (최근 30일)
Jorg
Jorg 2013년 10월 1일
답변: Alberto 2014년 4월 10일
Hi, I have a structure containing different sub-fields, and I want to write some of them to a file.
There are two sub-fields I want to write to the file: one a [1x3000 double] and one a [10000x10 double].
Anyway I tried to do this using ftprintf, but there is no order in the .txt-file. I could only get it to run as a script as well, while it should take the structure as an input in a function
Does someone know how to do this?

답변 (1개)

Alberto
Alberto 2014년 4월 10일
Take this as an example:
x={'1', '2', '3'}
fileName='test.txt'
fid=fopen(fileName, 'w')
for k=1:length(x)
fprintf(fid, '%s \n' , x{k});
end
fclose(fid)
I hope it will be helpful.

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by