How Can I Clearly Identify Differences? and How to Save and Display Data in Full Decimal Format?
1 view (last 30 days)
Show older comments
Hi, I have 2 data and I would like to check the differences.
According to Matlab, when I minus both data, it shows differences but when I copy the data directly from the Matlab workspace and minus it in MS Excel. it appears 0 (no differences) as shown in the attachment.
May I know how to see its difference in Matlab because I can't see any differences? And how to save and see all the data in full decimal? Is there a way to make the data tally in Excel and Matlab?
Below are the codes.
clear
clc
format long
load QuestionWorkspace
Data1
Data2
% It seems like no different but why there is different value after deduct it ?
Difference_Value= Data1-Data2
% How to see its different?
% However, when I copy the data in excel
% minus the both data it appears 0 ... no different...
% How to save and see all the data in full decimal?
Thanks in advance.
0 Comments
Accepted Answer
DGM
on 8 Apr 2024
Edited: DGM
on 8 Apr 2024
I'm going to assume that you're entering them into excel by trusting that
format long
will reveal the entire number. It won't really. You can get more digits other ways, though be aware that when changing base, you're not assured that the result actually can be represented in a finite number of digits. At some point, the results you get will just be junk.
load QuestionWorkspace
fprintf('%.18f\n',Data1)
fprintf('%.18f\n',Data2)
We can see that the numbers are definitely not the same, but if you had copied them from the console window using the formatting you'd used before, then you're reducing the precision enough that they are the same.
Alternatively, please consider that I haven't used Excel in a decade, and I don't use the modern tools for writing to xlsx files. If for some reason, the data were converted to single precision floats, then you'd lose enough precision that the numbers would indeed become equal.
More Answers (0)
See Also
Categories
Find more on Data Import from MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!