Search code examples
javamatlabadjacency-matrixcytoscape

Reading and Processing .mat file (Adjacency Matrix) in Java


I have covered lots of StackOverflow questions and Google search results, read many discussion topics but I couldn't find any proper answer for my question. I have an Sparse Matrix in .mat format which contains 36600 nodes (36600x36600 adjacency matrix) to read and manipulate (like matrix vector multiplication) in Java Environment. I applied many answers that discussed at here but I always got NullPointerException errors although there was a data at that .mat files.(Some says these result is because of size of data) I have applied these following code to my .mat file that return null and NullPointerException.

MatFileReader matfilereader = new MatFileReader("sourceData.mat");
MLArray mlArrayRetrieved = matfilereader.getMLArray("data");
System.out.println(mlArrayRetrieved);
System.out.println(mlArrayRetrieved.contentToString());

Also I have tried many times to convert .mat file to .csv or .xls in MATLAB Environment and Python Environment at Jupyter Notebook but, I did not get any result at these times, too.

That .mat file is going to be a adjacency matrix and will be a source for a specific algorithm in Cytoscape project. Hence, I must use it at Java Environment and I have decided to use the COLT Library for matrix manipulations. Suggestions and advises are going to help me so much. Thanks for reading.


Solution

  • just use find to get rows, columns and values of nonzeros elements and save these as text,csv or...:

    [row, col, v] = find(my_spares_matrix);