问题
I am using this code to get the numeric data from the file I am studying:
[FileName,PathName]= uigetfile('*.txt*','Files to Study');
%fullfile puts pathname and filename into one file so it can be used to
%import data from the chosen file
file =fullfile(PathName,FileName);
A = [];
fid = fopen(file);
tline = fgets(fid);
while ischar(tline)
parts = textscan(tline, '%d;');
if numel(parts{1}) > 0
A = [ A ; parts{:}' ];
end
tline = fgets(fid);
end
fclose(fid);
X = A(:,2)
Y = A(:,7)
It works fine, but the issue I am having is: when the numbers are displayed in the command window they have been rounded from numbers with decimal points to whole numbers.
For example from:
165.98
166.38
166.78
167.18
167.57
167.97
168.37
168.77
169.17
169.56
169.96
170.36
170.76
171.16
171.55
171.95
to this:
166
166
167
167
168
168
168
169
169
170
170
170
171
171
172
Is there some change I could make to my code to display the original data rather that the rounded whole numbers?
来源:https://stackoverflow.com/questions/23492523/how-to-prevent-a-decimal-number-being-rounded-to-a-whole-number