Unable to read from text file
1 回表示 (過去 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!