Custom defined data class not recognized

5 vues (au cours des 30 derniers jours)
Christopher Fromme
Christopher Fromme le 17 Nov 2021
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

Réponse acceptée

Steven Lord
Steven Lord le 17 Nov 2021
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 commentaire
Christopher Fromme
Christopher Fromme le 17 Nov 2021
🤦‍♂️😂
Now it seems pretty obvious... I hadn't seen any example though.
Thanks a lot! :)

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by