Unable to read from text file
조회 수: 2 (최근 30일)
이전 댓글 표시
My textfile(sample pasted below) contains sequence of numbers.
Below is my snippet of code to read it:
jointAngle = strcat('/mnt/seagate/dataset/RobotDemo/joint_angles/',jointAngles(1).name)
fileID = fopen(jointAngle,'r')
formatSpec = '%f';
A = fscanf(fileID, formatSpec)
My output:
jointAngle= '/mnt/seagate/dataset/RobotDemo/joint_angles/1489512207.73.txt'
A = []
1) Why is my file not being read? 2) How can I convert this text content into arrays to plot a graph?
Sample.txt
-3.01772370152
-1.56849535382
1.21606326821
-0.371606845441
0.495475793921
-2.06473813813
1.36600989005
-0.0452524331909
-0.608606876898
0.0
-0.461344721429
-0.995170035004
0.704480676031
-12.5659871048
1.59840797915
1.80894684205
1.25556327345
Thanks!
댓글 수: 2
KSSV
2017년 3월 15일
What error you get? You have to check your path...are you giving the path correctly?
Star Strider
2017년 3월 15일
Where in your code did you put:
A = []
If you put it after you read the file, you deleted everything in ‘A’.
답변 (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!