How do I separate data into different columns from a text file?
古いコメントを表示
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.
回答 (1 件)
Star Strider
2018 年 3 月 20 日
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.
カテゴリ
ヘルプ センター および File Exchange で Scripts についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!