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

3 ビュー (過去 30 日間)
Luca D'Angelo
Luca D'Angelo 2023 年 9 月 30 日
回答済み: Piyush 2023 年 10 月 11 日
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 Center および File ExchangeData 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