Unable to read from text file

1 次查看(过去 30 天)
Emmanuel
Emmanuel 2017-3-15
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
KSSV 2017-3-15
What error you get? You have to check your path...are you giving the path correctly?
Star Strider
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 个)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by