How can i read certain columns from txt file and save them for later usage?

hello, i would like to ask for some help, because i am in the beginning of learning matlab. So i have a txt file with 11 columns but i only need 3 of them without the headers (1,3 and 4). How can i make it read only them and save them in an array for using them later in the script.
i will upload the file and would appreciate any suggestions! Thank you

Respuestas (1)

KALYAN ACHARJYA
KALYAN ACHARJYA el 9 de Ag. de 2019
Editada: KALYAN ACHARJYA el 9 de Ag. de 2019
data_file=load('Aerosil_C10_T40_001.txt');
j=[1,3,4]; %define column number
colm_dada=data_file(:,j); % Column data for further use
Save colm_data
writetable(colm_data, 'file_name1.txt');
Now you can acess the file_name1.txt file in future work

3 comentarios

Hi, and thank you, but it has a problem with the function load.
i am trying now this way, but it shows me only 0 as results:
fid = fopen('Aerosil_C10_T40_001.txt', 'r');
T = textscan(fid, '%f %*f %f %f %*f %*f %*f %*f %*f %*f %*f','headerLines',3,'delimiter', ' ');
fclose(fid);
data=T{1:3:4}
Have you tried as answered?
Thanks so much for this answer as it was exactly what I needed!

Iniciar sesión para comentar.

Categorías

Más información sobre Data Import and Export en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 9 de Ag. de 2019

Comentada:

el 2 de Dic. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by