Custom defined data class not recognized

5 ビュー (過去 30 日間)
Christopher Fromme
Christopher Fromme 2021 年 11 月 17 日
コメント済み: Christopher Fromme 2021 年 11 月 17 日
Hello,
I'm trying to define my own data class in a package as described in Define Data Classes.
I've created the following folder structure:
D:\_rep\library\MATLAB_packages\+fwpck\@GlobalParam\
In that folder I created the file 'GlobalParam.m' with the following content:
classdef GlobalParam < Simulink.Parameter
%--------------------------------------------------------------------------
properties(PropertyType = 'double scalar')
ConversionFactor = 1;
end
%--------------------------------------------------------------------------
methods
function obj = GlobalParam(type, value, convFact, min, max)
% GlobalParam Class constructor
% call superclass constructor
obj@Simulink.Parameter();
% set properties
obj.DataType = type;
obj.Value = value;
obj.ConversionFactor = convFact;
obj.Min = min;
obj.Max = max;
end
end
end % classdef
I added the path 'D:\_rep\library\MATLAB_packages\' and tried the following code line:
>> globalParam1 = GlobalParam('single', 145.45, 0.34, 100, 200);
This results in the error
Unrecognized function or variable 'GlobalParam'.
What am I missing?
Any help would be highly appreciated. :)
Thanks
Christopher

採用された回答

Steven Lord
Steven Lord 2021 年 11 月 17 日
That class is part of the fwpck package. You will need to call it using the package name or import the package.
y = fwpck.GlobalParam('single', 145.45, 0.34, 100, 200);
  1 件のコメント
Christopher Fromme
Christopher Fromme 2021 年 11 月 17 日
🤦‍♂️😂
Now it seems pretty obvious... I hadn't seen any example though.
Thanks a lot! :)

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by