Storing UI component names in a property
2 ビュー (過去 30 日間)
古いコメントを表示
Hi! I am developing an app, and I've run into a problem. My app requires changing image sources for multiple different images, and so I decided to create a function that does that. I want to store the path to image sources in a property, as this would greatly reduce the complexity of the rest of the code, and so I tried to create a property imagenum like this:
properties (Access = private)
imagenum = [app.IM1.ImageSource app.IM2.ImageSource app.IM3.ImageSource app.IM4.ImageSource app.IM5.ImageSource app.IM6.ImageSource app.IM7.ImageSource app.IM8.ImageSource app.IM9.ImageSource app.IM10.ImageSource app.IM11.ImageSource app.IM12.ImageSource app.IM13.ImageSource app.IM14.ImageSource]
images = ['1.png', '2.png', '3.png', '4.png', '5.png', '6.png']
lettnum
corg
end
The corg, images and lettnum properties are there for the function, no problems with these.
And the function would look like:
function imageset(app,imnum)
if app.corg(imnum) == 1
app.imagenum(imnum) = app.images(app.wlettnum(imnum));
end
The error I get is
Error using Mainapp/GoPressed (line 60)
Invalid default value for property 'imagenum' in class 'PlayApp':
Unable to resolve the name app.IM1.ImageSource.
And so, I want to ask if there's any way to save a UI component property i.e. app.IM1.ImageSource in an app's property so it can be accessed by a function? I've tried multiple ways(saving the name as char type, string type, including .ImageSource in the function and in property), but none of these seem to be working, unless I'm missing something.
0 件のコメント
回答 (1 件)
参考
カテゴリ
Help Center および File Exchange で Environment and Settings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!