Why does ISFIELD always return FALSE when querying a user-defined class in MATLAB 7.7 (R2008b)?

14 次查看(过去 30 天)
When I use the function ISFIELD on a MATLAB class object, it always returns false, even when I know that the queried property is there.
The class definition includes a property called 'myproperty'
classdef myclass
properties
myproperty = 0;
end
end
When I check the presence of a property as follows:
x=myclass
isfield(x,'myproperty')
ISFIELD always returns a FALSE
ans =
0

采纳的回答

MathWorks Support Team
Using ISFIELD on a user defined MATLAB class is not supported in MATLAB 7.7 (R2008b).
As a workaround, use the following to determine if a property exists for a class:
any(strcmp(properties(x), 'myproperty'))

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Structures 的更多信息

产品


版本

R2008b

Community Treasure Hunt

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

Start Hunting!

Translated by