Effacer les filtres
Effacer les filtres

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

3 vues (au cours des 30 derniers jours)
SUSIE RYU
SUSIE RYU le 26 Mai 2020
Commenté : SUSIE RYU le 28 Mai 2020
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 commentaire
Mohammad Sami
Mohammad Sami le 26 Mai 2020
I assume "image" a uiimage element. If that is true, set the ImageSource propery instead.
app.image.ImageSource = 'CT4.png'; %etc

Connectez-vous pour commenter.

Réponse acceptée

Adam Danz
Adam Danz le 26 Mai 2020
Modifié(e) : Adam Danz le 27 Mai 2020
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.

Plus de réponses (0)

Catégories

En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by