Import data: com.mathwo​rks.jmi.Ma​tlabExcept​ion: Arrays have incompatible sizes for this operation

3 次查看(过去 30 天)
Hi all,
I want to import a huge .csv file recoursively with a script that I'm writing. In order to understand the best script to import the data I used the "Import data" function in the "Home" tab in Matlab.
I attached here a small version of the input file. If you try to open it with excel (just to check what the imput is) you'll find out that the first 7th rows are actually the headerline and excel can't allign it in only one row. The 8th and 9th rows, instead, are the corresponding data.
Now, "Import data" is not even able to open the preview since it says "com.mathworks.jmi.MatlabException: Arrays have incompatible sizes for this operation.".
Any suggestion?
Thanks,
Luca

回答(1 个)

Piyush
Piyush 2023-10-11
Hi @Luca D'Angelo,
I understand that you are facing trouble loading your '.csv' dataset in MATLAB. The dimension of the dataset is such that the first seven rows comprise of the headerline whereas the actual data begins from the 8th row. You also witness that importing the data into MATLAB does not even display the preview but throws an exception, "com.mathworks.jmi.MatlabException: Arrays have incompatible sizes for this operation."
I tried reproducing the issue on my end but I am able to load the excel file without any issues. The loaded table is in the same format where the first 7 rows has the headerline data and with same sparsity as available in dataset. You may prefer updating MATLAB to the latest version which includes various bug fixes and thereby allowing you to load the dataset without any issues. Once the data has been loaded into the MATLAB session you can use the "reshape" function to structure the matrix by explicitly specifying the dimension and achieving the goal of having the seven rows as single row headerline.
Please refer to the following MathWorks documentation link for more information on "reshape":
Hope this helps!

类别

Help CenterFile Exchange 中查找有关 Data Import from MATLAB 的更多信息

标签

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by