How to load .mat in the C++ environment?

9 次查看(过去 30 天)
I'm going to convert matlab code to C++.
I have to first load .mat file in the C++ environment.
So I finded matdgns.c file in the matlab environment.
but I don't know How to use it in the C++ environment (Visual Studio).
Is this matdgns.c use on C++ Visual Studio right ?
matdgns.c file is finded from matlab.
I referenced url below.
https://kr.mathworks.com/help/matlab/matlab_external/reading-a-mat-file-in-cc.html

回答(1 个)

Sumit Ghosh
Sumit Ghosh 2024-2-7
I am not sure whether matgdns.c is what you need, but you can achieve this using coder.read and coder.write
In short, coder.write(fileName,data) stores the argument data in a file with the name fileName.coderdata in your current directory. You can use this function in your host machine to sae the paraleters in a file.
dataFromFile = coder.read(fileName) reads from the fileName.coderdata storage file and returns the data stored within the file. You can use this function in your MATLAB® code for which you want to generate C/C++ code. The generated code performs the data read at run time.

类别

Help CenterFile Exchange 中查找有关 Call C++ from MATLAB 的更多信息

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by