MATLAB: Reading a .mat file in c/c++ .mat filec/c++readingstruct I am reading a big .mat file in c/c++. That mat file has nested struct and depth. How can i read this file? Thanks in advance. Best Answer Use the mat API functions from the library (e.g., matOpen, matGetVariable, etc):http://www.mathworks.com/help/matlab/read-and-write-matlab-mat-files-in-c-c-and-fortran.htmlIf you need to convert to/from a MATLAB struct and a C/C++ struct then you will need to copy each and every field element one-by-one (e.g., using mxGetField etc.) Related SolutionsMATLAB: Is matlab not allowing me to load this data Somehow your .mat file got overwritten with a single text '0' . You will need to get another copy of the file. MATLAB: How to load .mat files from a Hadoop filesystem MATLAB offers the "datastore" object to access remote data on systems like HDFS:https://www.mathworks.com/help/matlab/import_export/read-remote-data.html#bvn_hcu-3You can use the "fileDatastore" function to load MAT-files from HDFS, as shown:% Create a fileDatastore for the MAT-file on HDFS.ds = fileDatastore('hdfs://myserver/path_to_file.mat', 'ReadFcn', @load);% Read the MAT-file into the workspace.s = read(ds);Additional information on "fileDatastore" and its arguments is available in the documentation:https://www.mathworks.com/help/matlab/ref/matlab.io.datastore.filedatastore.html Related QuestionAccess value of Enumeration from C/C++ mex functionIs there documentation on the structure of MAT-files in MATLABIs possible to access to a MAT-file during the HIL simulation
Best Answer