Reading in a text file and creating multiple arrays
Mostra commenti meno recenti
I have a large text file. The first two lines appear as follows:
// cor=0.2 n=4000 N=10000
// r u_effe averg
Below that I have a bunch of lines of text with 4 columns. Then after the block of code finishes, I have 2 blanks lines, and then another 2 lines of code as above, but with cor=0.3. This goes on and on. Can I load this txt file into MATLAB and break up these into arrays with the different arrays named cor-0.2, cor-0.3 etc?
I have attached some sample code
Risposte (1)
Walter Roberson
il 7 Mar 2019
0 voti
You can use the same kind of technique I showed in https://www.mathworks.com/matlabcentral/answers/447889-how-do-i-read-data-from-a-dat-file-seperated-by-lines-of-text-into-individual-vectors#answer_363508
4 Commenti
Benjamin
il 7 Mar 2019
Walter Roberson
il 7 Mar 2019
import tool cannot do the work.
You should avoid writing to separate variables; see http://www.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-should-not-be-named-dynamically-eval
Do you need to preserve any of the numbers from the cor= line? Or just the numeric array below that?
Benjamin
il 7 Mar 2019
Benjamin
il 7 Mar 2019
Categorie
Scopri di più su Characters and Strings in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!