How to fake an app handle in the arguments?
6 次查看(过去 30 天)
显示 更早的评论
Hello.
I am working on a project which involves an app. What I do is to give the submethods a handle to the app, so that they can use the apps getter and setter methods, as well as the log file. This is done via Argument Validation, aka:
function [] = myFun(I, app, opt)
arguments
I (:, :) uint8 % the image
app (1, 1) eva
% Handle back to the app, to transfer data
opt.whatever1 (1, 1) {mustBeNumeric} = 100
opt.whatever2 (1, 1) {mustBeNumeric} = 100
opt.debug (1, 1) logical = false
end
% Function code
end
Now what I would like to do, is to be able to call the function like myFun(I, ?, 'debug', true), where I use the debug flag to not go into the parts of the code which actually uses the app handle. This would allow me to call the methods in the command line and not just from inside the app. In this case the '?' stands for whatever can be used. Empty strings or arrays do not work. Naively I'd use something like a Nullpointer, but I don't know if something like that exists in Matlab.
Any ideas or insights would be chuffing tremendous. Or if you know that this won't work as intended, that'd be good to know as well.
0 个评论
采纳的回答
dpb
2022-10-5
Use mustBeScalarOrEmpty validation function instead of fixed size would get past that hurdle. I've no klew whether it'll actually work as intended or not, I've never used any of the argument validation stuff...
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Develop Apps Using App Designer 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!