フィルターのクリア

Getting information through mex about caller workspace variables

1 回表示 (過去 30 日間)
Jagdish
Jagdish 2013 年 12 月 13 日
コメント済み: James Tursa 2020 年 9 月 22 日
I am interested in an implementation of the 'save' matlab function using c mex when only a single argument (the filename) is used as an input. The load version (mexload.c) is implemented and located in the mex folder of the examples folder, but there is no implementation of the save version. The primary issue I am having is how I can determine the number of variables and names of those variables in the caller's Matlab workspace from a c-mex file. There seems to be a function called mexGetVariable but you need to know the name of the variable a priori. Could anyone let me know if there is a way to do this?

回答 (1 件)

Jacob Halbrooks
Jacob Halbrooks 2013 年 12 月 17 日
In MATLAB, I would use WHOS to inspect the workspace for variables. If I was writing a function and needed to inspect the caller's workspace, I would use EVALIN, like this:
function showCallerWS
whosOutput = evalin('caller','whos');
From a MEX-file, you might be able to use mexCallMatlab to similar effect.
  3 件のコメント
yuge sun
yuge sun 2020 年 9 月 18 日
whats the detailed code when using 'mexCallMATLAB; evalin' to get variables from the base workspace, icant implement it correctlt.
James Tursa
James Tursa 2020 年 9 月 22 日
@yuge: Are you trying to get pointers to the variables, get copies of the variables, or get a list of the variable names?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeWorkspace Variables and MAT-Files についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by