Calling matlab from c++
古いコメントを表示
Hello! I created a simply matlab funcion
function addFunc(a,b)
plot(a,b);
end
and I compiled it to a lib and dll.
#include "stdafx.h"
#include "engine.h"
#include "addFunc.h"
#pragma comment(lib, "libmat.lib")
#pragma comment(lib, "libmx.lib")
#pragma comment(lib, "libmex.lib")
#pragma comment(lib, "libeng.lib")
#pragma comment(lib, "addFunc.lib")
#pragma comment(lib, "mclmcrrt.lib")
So what next? how can I call this function from VS?
Thanks!
7 件のコメント
James Tursa
2018 年 5 月 16 日
It's not clear what you are trying to do. Why is your code compiled into a lib and dll? What other code is using this lib or dll? Is that other code starting a MATLAB Engine? Are you trying to plot native C++ variables using the MATLAB Engine? Etc etc.
We need more details about what specifically you are trying to do.
Yoni Berk
2018 年 5 月 17 日
James Tursa
2018 年 5 月 17 日
By "standalone" do you mean running on a machine without MATLAB installed? Or do you mean a program that starts a MATLAB Engine off to the side and sends variables there for processing/plotting?
Yoni Berk
2018 年 5 月 17 日
Yoni Berk
2018 年 5 月 17 日
回答 (1 件)
Akshat Dalal
2025 年 5 月 12 日
0 投票
Hi Yoni,
My understanding is that the error you are facing regarding "that function or variable 'javaaddpath' is undefined" is expected. This is because the generated code probably has some interfacing with MATLAB which is being used to execute MATLAB code on the MATLAB engine. However, since you're trying to create a standalone application with MATLAB, 'javaaddpath' being an inbuild MATLAB function is undefined. You can debug this further to identify where the MATLAB Engine is being exectued and instead use your own custom piece of code. I might be wrong but this is what seems to be the issue.
カテゴリ
ヘルプ センター および File Exchange で C Shared Library Integration についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!