Unnecessary rounding when reading an xlsx
이전 댓글 표시
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
Adam Danz
2020년 7월 29일
Have you confirmed that your raw data are all unique points?
Could you attach a mat file containing the imported variable?
Emily Barber
2020년 7월 29일
Emily Barber
2020년 7월 29일
Clearly the xlsread output is greater than 4dp precision
format long
>> EElas(1:10,:)
ans =
0.000010000000000 35.397709999999996
0.000010625000000 34.404020000000003
0.000011250000000 33.496060000000000
0.000011875000000 32.662320000000001
0.000012500000000 31.893370000000001
0.000013750000000 30.519690000000001
0.000015000000000 29.325990000000001
0.000016250000000 28.276740000000000
0.000017500000000 27.345490000000002
0.000018750000000 26.512090000000001
I don't understand the point of the iRow loop. If any of the rows contained duplicate values, the code would break just after the loop when you contatenate the "c" values since at least one cell would only contain 1 value.
I haven't looked too deeply at the rest of the code but I ran it and it does not produce an error. So I'm a but lost as to how I can help. My answer was written before seeing your updated code so my answer may not be entirely relevant. However, I do recommend using readmatrix instead of xlsread.
Emily Barber
2020년 7월 29일
Adam Danz
2020년 7월 29일
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.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!