フィルターのクリア

MATLAB : Add path of parent directory containing a class, called from a child directory

21 ビュー (過去 30 日間)
Yoshua CELNIKIER
Yoshua CELNIKIER 2022 年 12 月 21 日
編集済み: Jan 2022 年 12 月 21 日
Hi all,
I have a directory 'C:\Users\Documents\VALID_AUTO\Generator' containing files (.m) and among them a Class named 'SignalStructureProperty'. In this directory, I have created a folder named 'C:\Users\Documents\VALID_AUTO\Generator\G_UnitTest'. From G_UnitTest, I have a script that tries to create the object signalStructureProperty = SignalStructureProperty. But running this script I have a Matlab message :
Undefined function or variable 'SignalStructureProperty'
I don't know how I can make Matlab understand that he should add the parent path of G_UnitTest, without giving an absolute path but relative to the G_UnitTest path, so that he could then "know" the class I want to instantiate.
Thanks in advance

回答 (1 件)

Jan
Jan 2022 年 12 月 21 日
編集済み: Jan 2022 年 12 月 21 日
What's wrong with using the absolute path?
myPath = mfilename('fullpath');
myParentPath = fileparts(myPath);
oldPath = addpath(myParentPath, '-end')
... your tests
path(oldPath); % Restore original path

カテゴリ

Help Center および File ExchangeSearch Path についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by