How do I separate data into different columns from a text file?
Mostrar comentarios más antiguos
I am a beginner in terms of matlab and needed help on a project I am working on. I have a text file with several values (6 different categories) and I cannot seem to divide those values into six different columns on MatLab. Anyone can help me to understand how to write the code? Here is the txt file as an attachment so you can understand better.
Respuestas (1)
Star Strider
el 20 de Mzo. de 2018
I am not certain what you want.
This version copies column 1 to (498x2) matrices for each column, in case you need the information in column 1 for the others:
D = load('SJCPNTS200001020300.txt');
Col_2 = D(:, [1 2]); % [Column #1 Column #2]
Col_3 = D(:, [1 3]); % [Column #1 Column #3]
This version copies columns 2 through 7 to different single columns:
Col_2 = D(:,2); % Column #2
Col_3 = D(:,3); % Column #3
Continue for the rest. Give them meaningful variable names.
Categorías
Más información sobre Scripts en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!