I am working in App Designer, and I have 3 UIAxes objects, and I want to plot an image to each of them. Rather than duplicate code, I created a function taking the app and a UIAxes object: "function assignSub(app, axes)" In this function, I do some things to prepare the image and the axes, and then I call "image(axes, myImage);"
Only, I get an error: "Specify a UIAxes handle as first argument"
Now, I know, Matlab is weakly typed, but is there some way for me to reassure the compiler that axes is in fact a UIAxes handle? Or can I get it to just trust me on this? Or is it somehow NOT a UIAxes handle?
About that - the call for this function looks like "app.assignSub(app, app.subImage1);" for a variety of subImages. I tried changing "app.subImage1" to "@app.subImage1" which is kind of how you turn a function into a function handle, but that didn't fix it. I wouldn't be surprised if that isn't valid code at all.
If all else fails, I guess I can do the work of preparing the image and axes inside the function, and then have it return myImage, and only then do I call "image(app.subImage1, myImage);". Then the compiler doesn't need to realize that the UIaxes are UIaxes while they're in the function, only when they're accessed directly from app. But this would require me to duplicate code for each time I do this, rather than just having one function call for each.