Custom defined data class not recognized

8 visualizaciones (últimos 30 días)
Christopher Fromme
Christopher Fromme el 17 de Nov. de 2021
Comentada: Christopher Fromme el 17 de Nov. de 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

Respuesta aceptada

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

Iniciar sesión para comentar.

Más respuestas (0)

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by