How to check for a custom property in a table
14 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
is there an easy way to check if a Custom Property in a table has been set, i.e. if it exists?
I know I can pass a structure to UserData in a table with a series of fields and then use isfield to check if a field exists. I cannot find a similar way to check for properties. There is a command isprop but it either doesn't work for this or I am using it wrong. Also T.Properties.Customproperties is not a structure on which isfield can operate, even thought it uses the dot operator.
Here is a MWE
t = array2table(rand(10,3));
t = addprop(t,'LineWidth','variable');
t.Properties.CustomProperties
I want to check if LineWidth or DisplayName exist. One should give me 1, the other 0.
Thanks!
0 commentaires
Réponses (3)
Voss
le 17 Juin 2022
Modifié(e) : Voss
le 17 Juin 2022
isprop should work:
t = array2table(rand(10,3));
isprop(t.Properties.CustomProperties,'LineWidth')
isprop(t.Properties.CustomProperties,'DisplayName')
isprop(t,'LineWidth')
isprop(t,'DisplayName')
% add LineWidth property
t = addprop(t,'LineWidth','variable');
isprop(t.Properties.CustomProperties,'LineWidth')
isprop(t.Properties.CustomProperties,'DisplayName')
isprop(t,'LineWidth')
isprop(t,'DisplayName')
2 commentaires
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!