Why I the data processed by the matlab is wrong, it reports three wrong results,what is the reason?All the data and .m files are included ,who can help me?

2 次查看(过去 30 天)
Why I the data processed by the matlab is wrong, it reports three wrong results,what is the reason?All the data and .m files are included ,who can help me?
  5 个评论
huazai2020
huazai2020 2020-6-25
You see the yellow word, the left are the primary data,the right are the process data, you see they are different, what is the reason?

请先登录,再进行评论。

回答(3 个)

Image Analyst
Image Analyst 2020-6-25
The display looks a little different but that's probably just due to the third column not being wide enough to show the same number of digits. Grab the divider line between the columns and widen it. It should look the same after that.
  1 个评论
huazai2020
huazai2020 2020-6-25
No, the value are not the same, the left is 0.58(Decimal), the right is 58469706(interger), they cannot be the same.You can use my data to have a try, you can find my problem.

请先登录,再进行评论。


Fangjun Jiang
Fangjun Jiang 2020-6-25
This is probably the limitation of the smartness of the importdata() function.
If you look at filec.textdata, you will get a clue. It tries to separate the data based on 'line-10'. 'line-10' is read in correctly. All the lines below, either the digit "0" or "0." are treated and included in as the text data.
So for 'line-20', "0" is truncated but ".5474641" is still read in as "0.5474641"
for "line-30', "0." is truncated thus "59778373" is read in as "59778373"
For your input file text format, it's better to use textscan(), although it can't be done with one line of code.
For this particular file "'tem-009.out'", I tried A=readmatrix(filename,'filetype','text') and it does give correct result.
  12 个评论
huazai2020
huazai2020 2020-7-5
Can I updata it directly to r2020a, or I should download a new one and setup it again.
What is the difference of importdata() or csvread() or dlmread()? Thank you.
Image Analyst
Image Analyst 2020-7-5
csvread() reads only comma separated values. dlmread() can have other delimiters in addition to commas. importdata() tries to be a smarter function than either of those two in that the data can be more complicated and it will try to figure it out.

请先登录,再进行评论。


Stephen23
Stephen23 2020-6-25
opt = {'CollectOutput',true };
[fid,msg] = fopen('tem-009.out','rt');
assert(fid>=3,msg)
str = '';
while ~strncmp(str,'-',1)
str = fgetl(fid);
end
C = textscan(fid,'line-%f%f',opt{:});
fclose(fid);
M = C{1};
Giving:
>> M
M =
10.0000 0.7539
20.0000 0.5475
30.0000 0.5978
50.0000 0.3828
70.0000 0.5847
90.0000 0.1664
110.0000 0.2465
130.0000 0.5116
150.0000 0.3211
160.0000 0.3744
170.0000 0.6611
  13 个评论

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Standard File Formats 的更多信息

标签

产品


版本

R2012b

Community Treasure Hunt

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

Start Hunting!

Translated by