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 CenterFile Exchange에서 Whos에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by