importdata() function stopped working in Matlab r2020b
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hallo everyone,
I have a script that uses the importdata() function on a .txt file with a 15 columns. If I run the script under r2019b or r2017b it works fine, if I run exactly the same script with r2020b it doesn't find anything in the file except for the headers. It's the same matlab script file and the same readout .txt file.
In 2019/2017 it would look like:
>>fil = 'C:/Location of file/file.txt'
>> M=importdata(fil)
M =
struct with fields:
data: [125×14 double]
textdata: {126×15 cell}
In 2020b it would look like:
>>fil = 'C:/Location of file/file.txt'
>> M=importdata(fil)
M =
struct with fields:
data: 0
textdata: {1×15 cell}
This has been tested both through script and by just using the above snippet in terminal.
Would anyone have an idea what is going on?
Thanks in advance
UPDATE: Apparantly the issue is somehow related to the hexadecimals. One of the columns is full of hexadecimals, which in Matlab r2020 are read out differently than in r2019. If I use readtable() function in 2020, it will read them, but as "uint 32" format, which could be converted back to the original hexadecimal by the dec2hex function. In 2019 version and below the same column is read in as an array of strings.
But that still does not explain why impordata() was able to read them before but is completely unable to read the full file (only one column is hexadecimals, if I remove it, it reads the file fine) in the 2020 version.
3 comentarios
Ajay Neeli
el 24 de Nov. de 2020
I tried to reproduce this error at my end. I tried to import a text file which has a column of hexadecimals. I tried to import in R2020a, R2018b, R2019b versions. All of them produce the same results. This error might be more than just importdata() function.
Here is the text file I have used for import -
myfile01.txt:
Day1 Day2 Day3 Day4 Day5 Day6 Day7
95.01 76.21 61.54 40.57 5.79 20.28 A
23.11 45.65 79.19 93.55 35.29 19.87 A
60.68 1.85 92.18 91.69 81.32 60.38 A
48.60 82.14 73.82 41.03 0.99 27.22 A
89.13 44.47 17.63 89.36 13.89 19.88 A
The commands I have used for
A = importdata('myfile01.txt',' ',1)
R2020a, R2019b, R2018b produce same output.
A =
struct with fields:
data: [5×7 double]
textdata: {'Day1' 'Day2' 'Day3' 'Day4' 'Day5' 'Day6' 'Day7'}
colheaders: {'Day1' 'Day2' 'Day3' 'Day4' 'Day5' 'Day6' 'Day7'}
Respuestas (0)
Ver también
Categorías
Más información sobre Spreadsheets en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!