How to import data from .txt file?
조회 수: 73 (최근 30일)
이전 댓글 표시
Hi All,
Ive tried importing my data via this code;
Spill = importdata('Spill.txt');
T = Spill(:,1);
C = Spill(:,2);
plot(T,C)
xlabel('Time / Days');
ylabel('Concentration / ppb')
but it doesn't work as it says "Index exceeds matrix dimensions.". It needs to be inputted by code and not just the import button. Can someone help? Ive attached the .txt file
댓글 수: 0
채택된 답변
Azzi Abdelmalek
2016년 4월 13일
편집: Azzi Abdelmalek
2016년 4월 13일
Spill1 = importdata('Spill.txt');
Spill=Spill1.data
T = Spill(:,1);
C = Spill(:,2);
plot(T,C)
xlabel('Time / Days');
ylabel('Concentration / ppb')
댓글 수: 0
추가 답변 (2개)
parham kianian
2020년 9월 2일
I think it is much easier to use textread function. Following link describe in full detail how to use this function to import data from a text file:
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Import and Analysis에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!