plot graph from text document
16 ビュー (過去 30 日間)
古いコメントを表示
I want to plot time vs w from the text document. I want to plot time vs w from the text document. And I tried the following codes from similar question but my problem is that the number after the decimal point of the value read by matlab is missing.
fid=fopen('file.txt')
s=textscan(fid,'%d %d %d','headerlines',23)
fclose(fid)
x=s{1}
y=s{2}
z=s{3}
plot(x,z)
the text:
Time ea w
0.000000 0.000000 -0.010000
0.010000 0.000000 -0.010000
0.010000 0.000000 -0.010000
0.020000 0.000000 -0.010000
0.020000 0.000000 -0.010000
0.030000 0.000000 -0.010000
0.030000 0.000000 -0.010000
0.040000 0.000000 -0.010000
0.040000 0.000000 -0.010000
0.050000 0.000000 -0.010000
0.050000 0.000000 -0.010000
0.060000 0.000000 -0.010000
0.060000 0.000000 -0.010000
0.070000 0.000000 -0.005000
0.070000 0.000000 -0.005000
0.080000 0.000000 -0.005000
0.080000 0.000000 -0.005000
0.090000 0.000000 -0.005000
0.090000 0.000000 -0.005000
0.100000 0.000000 -0.005000
0.100000 0.000000 -0.005000
0.110000 0.000000 -0.005000
0.110000 0.000000 -0.005000
0.120000 0.000000 -0.005000
0.120000 0.000000 -0.005000
0.130000 0.000000 -0.005000
0.130000 0.000000 -0.005000
0.140000 0.000000 -0.005000
0.140000 0.000000 -0.005000
0.150000 0.000000 -0.005000
0.150000 0.000000 -0.005000
0.160000 0.000000 -0.005000
0.160000 0.000000 -0.005000
0.170000 0.000000 -0.005000
0.170000 0.000000 -0.005000
0.180000 0.000000 -0.005000
0.180000 0.000000 -0.005000
0.190000 0.000000 -0.005000
0.190000 0.000000 -0.005000
0.200000 0.000000 -0.005000
0.200000 0.000000 -0.005000
0.210000 0.000000 -0.005000
0.210000 0.000000 -0.005000
0.220000 0.000000 -0.005000
0.220000 0.000000 -0.005000
0.230000 0.000000 -0.005000
0.230000 0.000000 -0.005000
0.240000 0.000000 -0.005000
0.240000 0.000000 -0.005000
0.250000 0.000000 -0.005000
0.250000 0.000000 -0.005000
0.260000 0.000000 -0.005000
0.260000 0.000000 -0.010000
0.270000 0.000000 -0.010000
0.270000 0.000000 -0.010000
0.280000 0.000000 -0.010000
0.280000 0.000000 -0.010000
0.290000 0.000000 -0.010000
0.290000 0.000000 -0.010000
0.300000 0.000000 -0.010000
0.300000 0.000000 -0.010000
0.310000 0.000000 -0.010000
0.310000 0.000000 -0.010000
0.320000 0.000000 -0.010000
0.320000 0.000000 -0.010000
0.330000 0.000000 -0.005000
0.330000 0.000000 -0.005000
0.340000 0.000000 -0.005000
0.340000 0.000000 -0.005000
0.350000 0.000000 -0.005000
0.350000 0.000000 -0.005000
0.360000 0.000000 -0.005000
0.360000 0.000000 -0.005000
0.370000 0.000000 -0.005000
0.370000 0.000000 -0.005000
0.380000 0.000000 -0.005000
0.380000 0.000000 -0.005000
0.390000 0.000000 -0.005000
0.390000 0.000000 -0.010000
0.400000 0.000000 -0.010000
0.400000 0.000000 -0.010000
0.410000 0.000000 -0.010000
0.410000 0.000000 -0.010000
0.420000 0.000000 -0.010000
0.420000 0.000000 -0.010000
0.430000 0.000000 -0.010000
0.430000 0.000000 -0.010000
0.440000 0.000000 -0.010000
0.440000 0.000000 -0.010000
0.450000 0.000000 -0.010000
0.450000 0.000000 -0.010000
0.460000 0.000000 -0.005000
0.460000 0.000000 -0.005000
.....................
0 件のコメント
回答 (2 件)
Star Strider
2015 年 9 月 15 日
Use the '%f' edit descriptor:
s=textscan(fid,'%f %f %f','headerlines',23);
0 件のコメント
Adam
2015 年 9 月 15 日
doc textscan
%d is used to specify an integer being read in.
You need to use %f to read a double or %f32 if you want to read a single. You can also use more precise versions to specify exactly the number of values to read before and after the decimal place if you require, as shown in the help linked
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Annotations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!