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