This sounds like a magic meta programming. I recommend to avoid such smart tricks and keep comments in the source code as usual. Bot of course it is possible:
obj.pmExpo.iter_comment = ['this is a comment indicating the use of this variable, ', ...
'so I do not need to go back to the code to know what it does'];
And now the function to display a field:
function MagicDisp(S, Field)
sprintf('Field: %s\n', Field);
disp(S.(Field));
Magic = [Field, '_comment'];
if isfield(S, Magic)
fprintf('%s\n', S.(Magic));
end
end
Now call it as:
MagicDisp(obj.pmExpo, 'iter')
Well, the name "MagicDisp" implies, that I would not use it for productive code. The function could be enhanced, but I would not do it, because variable which do explain their meaning actively are too tricky to be useful. What would happen if you run a larger code, which uses 200 of such variables and process them in a loop?
If a variable should do anything actively, that it would be starting the daily backup. This is more important, forgotten too often, and the explanations can appear in the code instead.
Best Answer