how to read column under a string in a text file?
Mostrar comentarios más antiguos
Hy how can i read the column of numbers under the 'FOE' in the text file? that column may be the first, last or any column between them.
thanks in advance for all the advice u can provide
Respuestas (1)
madhan ravi
el 24 de Oct. de 2018
Editada: madhan ravi
el 24 de Oct. de 2018
opts = detectImportOptions('123.txt');
opts.SelectedVariableNames = {'FOE'};
T=readtable('123.txt',opts);
FOE=table2array(T(:,1))
COMMAND WINDOW displays as below:
>>FOE =
1.25e-05
3.82e-05
8.78e-05
0.000188
0.000251
0.000377
0.000553
0.00078
0.001019
0.001139
0.001258
0.001378
0.001617
0.001832
0.002175
0.002519
0.003037
0.00341
0.003783
0.004099
0.004327
0.004504
0.004776
0.005049
0.005315
0.005556
0.005746
0.006031
0.006171
0.006317
0.006609
0.00685
0.007218
0.007587
0.007904
0.008381
0.008858
0.009175
0.009653
0.010129
0.010766
0.010842
0.01088
0.01088
0.011109
0.011249
0.011402
0.011707
0.011949
0.012312
0.01249
0.012675
0.013044
0.013496
0.013713
0.013949
0.014178
0.014407
0.014509
0.014713
0.014968
0.015222
0.015477
0.015604
0.015732
0.015859
0.015987
0.016114
0.01621
0.016353
0.016497
0.016777
0.017018
0.017197
0.017484
0.017771
0.018342
0.018695
0.019046
0.019363
0.019594
0.019957
0.020317
0.020639
0.020869
0.021232
0.021595
>>
7 comentarios
madhan ravi
el 24 de Oct. de 2018
the above will read the variable FOE and you can use it for calculations
madhan ravi
el 24 de Oct. de 2018
if you got the answer you were looking for accept the answer so that other people know the question is solved else let know
Idin Pushkin
el 24 de Oct. de 2018
Editada: Idin Pushkin
el 24 de Oct. de 2018
madhan ravi
el 24 de Oct. de 2018
ok let me check will get back to you soon
madhan ravi
el 24 de Oct. de 2018
Editada: madhan ravi
el 24 de Oct. de 2018
unfortunately Matlab is not recognising variable names for this file
madhan ravi
el 24 de Oct. de 2018
You can unaccept the answer still you get the code to read this file
Idin Pushkin
el 24 de Oct. de 2018
Categorías
Más información sobre Characters and Strings en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!