How to write a big file

I need to write a .dat file to be read by a program. The problem is that this .dat has 2700 lines and I can not write fprint for each line. Here is an extract of the program:
CASO TESTE LE e LDireito
< MACH >< ALPHA >[ BETA ]< RE >< CAX >< SW >
0.840 0.30000 0. 33000000. 3.194 72.7200
[ ICL ][ CL ][ DCLDA ]
0. .45 .10
[ PSE ][ DELWING][ IBEAM ][ IAIL ][ IROT ][ IBLF ]
1. 0. 0. 0. 0. 0.
[ PA1 ]
0.70
[ PA2 ]
.77
Some of these numbers are not variable, so they can be written, but some are variables and must be %10f.
What can I do?
Thank you

1 Commento

Matt Kindig
Matt Kindig il 12 Lug 2013
Why can't you write fprintf for each line? How are the various fields (<MACH>, < DELWING>, etc.) determined? In what form is your current data?

Risposte (1)

per isakson
per isakson il 12 Lug 2013

0 voti

2700 rows of text should be no problem to write with fprintf and a loop. The resulting file will be a couple of MB at most. There is no better way.
You need to be more specific on the reason to why you write "I can not write fprint for each line."

2 Commenti

ita
ita il 12 Lug 2013
I think that I was not clear, sorry for my english. The idea is: matlab will evaluate 8 numbers (span of wing, thickness of airfoil,...) and these data will be used to write the .dat (this .dat is the file that my CFD program reads and it contains all specifications of the aircraft). So, to make Matlab to write the .dat for me I should write on the script a fprintf(fid,'...\n') for each line, and this is not feasable.
per isakson
per isakson il 12 Lug 2013
Modificato: per isakson il 13 Lug 2013
"and this is not feasable." Why? I cannot see any reason why not.
Let me get this clear. You write "Here is an extract of the program:", but the following lines are they not an excerpt of a .dat-file, i.e they display the required format of the .dat-file? That is, the result of the Matlab program, which you are developing.
CASO TESTE LE e LDireito
< MACH >< ALPHA >[ BETA ]< RE >< CAX >< SW >
0.840 0.30000 0. 33000000. 3.194 72.7200
[ ICL ][ CL ][ DCLDA ]
0. .45 .10
[ PSE ][ DELWING][ IBEAM ][ IAIL ][ IROT ][ IBLF ]
1. 0. 0. 0. 0. 0.
[ PA1 ]
0.70
[ PA2 ]
.77
This row
CASO TESTE LE e LDireito
is it a file-header, or is repeated throughout the .dat-file?
Then follows five pairs of one column header row and one data row. Is that correct? You write "evaluate 8 numbers [...] and these data will be used to write the .dat ", however I count to 17 numbers.
The .dat-file should contain 2700 groups of these five pairs of rows. Correct?

Questa domanda è chiusa.

Richiesto:

ita
il 12 Lug 2013

Chiuso:

il 20 Ago 2021

Community Treasure Hunt

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

Start Hunting!

Translated by