Why values get changed while doing indexing?
1 view (last 30 days)
Show older comments
Hello everyone,
My code is for collocating data of two satellites. Therefore at first I have checked the index where date of Satellite 1 is equal to date of Satellite 2. Later I started the loop.
for i = 1 : length(Files_list)
ind_1 = find(Sat1_date(i) == Sat2_date);
% other lines from this code...
Find_index = Data(ind_1,:) % at this point my values change
end
Data is:
But Find_index returns:
2.0170 0.0060 0.0040 0.0040 0.0250 0.0397 0.1320
Why is it happening like this?
0 Comments
Accepted Answer
Stephen23
on 14 Feb 2022
Edited: Stephen23
on 14 Feb 2022
"Why values get changed while doing indexing?"
They don't.
The values are exactly the same, they are simply displayed slightly differently. In particular, you are ingoring the common multiplier shown just above those numbers, which looks like it is 1e3.
Lets have a look, note the common multiplier is shown as 1.0+e03 * at the very top of the displayed text:
A = [1.23e3,4.56e3;0.5,9.8]
Does this mean that my data have magically been converted from 0.5 into 0.005 ? Of course not, the common factor shown at the top (1e3) applies to all of the values in the array. Lets look at just the values of the 2nd row:
A(2,:)
"Why is it happening like this? "
Because there is no one single universal way of displaying numbers. MATLAB tries to pick reasonable representations of numbers to display depending on the magnitude and number of digits, as explained here:
Some display formats also takes into account the values of total array, not just the individual elements.
You can change the format if you want, perhaps this does more what you expect:
format long G
A
0 Comments
More Answers (0)
See Also
Categories
Find more on Dates and Time 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!