modify import list of other scopes dynamically?

조회 수: 1 (최근 30일)
German Gomez-Herrero
German Gomez-Herrero 2012년 11월 5일
Is there a way in MATLAB to modify the import list of a scope different from the current one? That is, I would like to be able to do something like this:
function import_mypackage()
evalin('caller', 'import mypackage.*');
end
This doesn't work. No error is produced when calling import_mypackage(), but the namespace contained in mypackage is not imported, i.e:
function foo()
import_mypackage;
g(); % Wanted mypackage.g() but got: Undefined function or variable
end
I know that you can modify dynamically the import list of the current scope either using eval or by passing a variable to import(). However, I cannot find any way to modify the import list of other scopes. Is there any way?
NOTE: I know there are many good reasons for not doing what I am asking here, but I think I have one reason to actually need this (I can give more info if someone asks). In any case, I would like to know just out of curiosity whether this is possible.
Thanks in advance!

답변 (0개)

카테고리

Help CenterFile Exchange에서 Simulink Coder에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by