필터 지우기
필터 지우기

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

조회 수: 2 (최근 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에서 Spreadsheets에 대해 자세히 알아보기

태그

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by