Azzera filtri
Azzera filtri

How to write data to an exact row in a text file

1 visualizzazione (ultimi 30 giorni)
Hello, I need to edit a parameter text file for my task and I need to change the value on i.e. 30th row of that parameter file with a loop then save the file. I've tried to come up with a function that does the trick, but couldn't find a proper one.
I'll be faithful if someone can offer some guidance. Thanks in advance.
  2 Commenti
Azzi Abdelmalek
Azzi Abdelmalek il 2 Ott 2012
Modificato: Azzi Abdelmalek il 2 Ott 2012
What kind of data are in your file, why don't you post a sample of your text file?
don't comment your question with an answer, just post a comment like I did
Al Onen
Al Onen il 2 Ott 2012
Modificato: Al Onen il 2 Ott 2012
Sorry, I am kind of in a hurry, here is my text file that I need to reference. I will create a loop to change REFKDT_DATA value (line 24) for further analysis. I tried to create variable references one by one, but Matlab gave dataread error.
General Parameters
SLOPE_DATA
9
0.1
0.01
1.0
0.35
0.55
0.8
0.63
0.0
0.0
SBETA_DATA
-2.0
FXEXP_DATA
2.0
CSOIL_DATA
2.00E+6
SALP_DATA
2.6
REFDK_DATA
1.0E-6
REFKDT_DATA
2.0
FRZK_DATA
0.15
ZBOT_DATA
-8.0
CZIL_DATA
0.1
SMLOW_DATA
0.5
SMHIGH_DATA
3.0
REFMANN_DATA
8.0

Accedi per commentare.

Risposta accettata

Walter Roberson
Walter Roberson il 2 Ott 2012
There is no MATLAB function for changing a particular row of a text file. You will need to read the existing file and write a new copy of the file.

Più risposte (1)

Al Onen
Al Onen il 2 Ott 2012
Still waiting for an answer...

Categorie

Scopri di più su Data Import and Export in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by