Unable to read from text file

1 visualización (últimos 30 días)
Emmanuel
Emmanuel el 15 de Mzo. de 2017
Comentada: Star Strider el 15 de Mzo. de 2017
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 comentarios
KSSV
KSSV el 15 de Mzo. de 2017
What error you get? You have to check your path...are you giving the path correctly?
Star Strider
Star Strider el 15 de Mzo. de 2017
Where in your code did you put:
A = []
If you put it after you read the file, you deleted everything in ‘A’.

Iniciar sesión para comentar.

Respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by