I want to import image on app designer with drop down button

17 ビュー (過去 30 日間)
SUSIE RYU
SUSIE RYU 2020 年 5 月 26 日
コメント済み: SUSIE RYU 2020 年 5 月 28 日
Hello everyone.
I want to import image on app designer. Also, I would like to swith the image when drop down items changed.
How can i do it?
% Value changed function: PatientIDDropDown
function PatientIDDropDownValueChanged(app, event)
value = app.PatientIDDropDown.Value;
if (value=='5648834')
I1 = imshow('CT1.png', 'Parent', app.image)
elseif (value=='5648834')
I2 = imshow('CT2.png', 'Parent', app.image)
elseif (value=='5648834')
I3 = imshow('CT3.png', 'Parent', app.image)
elseif (value=='5648834')
I4 = imshow('CT4.png', 'Parent', app.image)
end
end
I make my code like above. However I got error message
Specify a UIAxes as the value for 'Parent'.
Best regard, SUE
  1 件のコメント
Mohammad Sami
Mohammad Sami 2020 年 5 月 26 日
I assume "image" a uiimage element. If that is true, set the ImageSource propery instead.
app.image.ImageSource = 'CT4.png'; %etc

サインインしてコメントする。

採用された回答

Adam Danz
Adam Danz 2020 年 5 月 26 日
編集済み: Adam Danz 2020 年 5 月 27 日
Your error message tells you exactly what you need to do.
"Specify a UIAxes as the value for 'Parent'."
It looks like you're using the correct syntax but app.image apparenlty is not a UIAxes. You should assign a UIAxes as parent.
I1 = imshow('CT4.png', 'Parent', app.UIAxes)
% ^^^^^^^^^^ whatever your axis handle is
Also, instead of using if-elseif, consider using a switch case,
switch value
case '5648834'
I1 = imshow('CT1.png', 'Parent', app.image);
case '5648834'
I2 = imshow('CT2.png', 'Parent', app.image);
case '5648834'
I3 = imshow('CT3.png', 'Parent', app.image);
case '5648834'
I4 = imshow('CT4.png', 'Parent', app.image);
otherwise
error('Did not recognized patient ID ''%s''.', value)
end
Lastly, all of your conditions (and all of my cases) are the same value '5648834' which must be a mistake.
  1 件のコメント
SUSIE RYU
SUSIE RYU 2020 年 5 月 28 日
Thanks for the help. Really appreciate it !

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by