Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

Replace a string in a file with a 1D array--please don't close it

1 vue (au cours des 30 derniers jours)
H R
H R le 4 Jan 2016
Clôturé : Walter Roberson le 4 Jan 2016
Hi all,
Please help me with this question. I have been trying to find a simple way to do so. Please don't close this.
I have a 1D number array with N numbers say A=[1,2,3,4,5,6,7,8,9,10,...100]; I have a text file 'Test.txt'. Inside the text file I have a string [$1].
Data
[$1]
/
How to replace the string [$1] with the content of the array A in such a way that the array content is written one after each other in multiple lines where only 6 space-delimited numbers are printed in each line except the last line that could be shorter than 6 numbers (depending on the size of A). After this I would like to save the file with other name say 'Test1.txt' with the following contents:
Data
1 2 3 4 5 6
7 8 9 10 11 12
13 14 15 16 17 18
...
/

Réponses (0)

Cette question est clôturée.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by