loading a 2d matrix from a text file comes in as an array
이전 댓글 표시
I have two columns of data in a text file that I'm trying to read in using the load function. For some reason it is loading the file as a single array (1 x 1340) instead of a matrix (670 x 2). I am using the 2012a and I'm on a Mac.
답변 (1개)
Azzi Abdelmalek
2013년 2월 22일
If its loading as a single array, depending on the order of your data you can For example:
x y
1 10
2 20
3 30
If the data comes like
data=[1 2 3 10 20 30]
n=numel(data)
x=data(1:n/2)
y=data(n/2+1:end)
If data comes like
data=[1 10 2 20 3 30];
x=data(1:2:end);
y=data(2:2:end)
카테고리
도움말 센터 및 File Exchange에서 Text Files에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!