Unnecessary rounding when reading an xlsx

9 Ansichten (letzte 30 Tage)
Emily Barber
Emily Barber am 29 Jul. 2020
Kommentiert: Adam Danz am 29 Jul. 2020
I currently need to input xlsx data into matlab to a precision of 7 decimal places, and then interpolate data inbetween those points. However, I'm relatively sure that the data is only being inputted to 4 decimal places, as the interp1 function is giving back the error: "The grid vectors must contain unique points" (it uses griddedInterpolant to solve the answer). This would happen if the program is rounding to 4 decimals, as I have some data that is 0.0000100, 0.0000106, etc.. Everything I see online, though, says that MATLab imports up to 15 decimal places. Is there something else that could be wrong here?
(Additionally, I have the format set to long)
Thanks.
  6 Kommentare
Emily Barber
Emily Barber am 29 Jul. 2020
I copied exactly what I sent you into a function and it worked, which means that something's likely wrong with my code as a whole (as it didn't work once placed in the function). I'll try to keep working with it, thank you for your help.
Adam Danz
Adam Danz am 29 Jul. 2020
Feel free to continue to discussion if you find the source the problem and have trouble fixing it. If the problem is greatly different from the conversation so far, it would be better to start a new question and you can provide a link to it here in the comment section if you'd like.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Adam Danz
Adam Danz am 29 Jul. 2020
Bearbeitet: Adam Danz am 29 Jul. 2020
Thanks for providing the raw data.
I'm not seeing what you're seeing. My data exporation steps are below.
% Read-in the data
x = readmatrix('U238Elastic.xlsx');
% Check out the first few rows
x(1:10,:)
% RESULT (format: shortg)
% ans =
% 1e-05 35.398
% 1.0625e-05 34.404
% 1.125e-05 33.496
% 1.1875e-05 32.662
% 1.25e-05 31.893
% 1.375e-05 30.52
% 1.5e-05 29.326
% 1.625e-05 28.277
% 1.75e-05 27.345
% 1.875e-05 26.512
Clearly the precision is greater than 4dp.
Are there any duplicate rows?
% Produce index of unique rows of x
[~, unqIdx] = unique(x,'rows');
isUnq = ismember(1:size(x,1), unqIdx);
% Compute the percentage of rows that are unique
percentUnq = sum(isUnq)/size(x,1)*100
% RESULT
% percentUnq =
% 100
It seems that all of the coordinates are unique. Maybe you're reading in the data differently or perhaps you're looking at a different pair of values than this.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by