Extracting Data from a Comma Separated List
6 次查看(过去 30 天)
显示 更早的评论
I would to take data from a list in the following form and store it in vectors:
1;2
3;4
5;6
7;8
However, I need the data to be stored in vectors in the following fashion so that it can be plotted:
[1 3 5 7]
and
[2 4 6 8]
What is the best way to go about doing this?
1 个评论
回答(2 个)
Azzi Abdelmalek
2015-7-25
If your data are stored in a text file
data=dlmread('file.txt')
r1=data(:,1)'
r2=data(:,2)'
0 个评论
Image Analyst
2015-7-25
Have you tried dlmread():
% Read from file with semicolon delimeter.
array2d = dlmread(filename, ';');
% Get column vectors and transpose into row vectors.
array1 = array2d(:, 1)';
array2 = array2d(:, 2)';
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Text Files 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!