Azzera filtri
Azzera filtri

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

3 visualizzazioni (ultimi 30 giorni)
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 Commento
Mohammad Sami
Mohammad Sami il 26 Mag 2020
I assume "image" a uiimage element. If that is true, set the ImageSource propery instead.
app.image.ImageSource = 'CT4.png'; %etc

Accedi per commentare.

Risposta accettata

Adam Danz
Adam Danz il 26 Mag 2020
Modificato: Adam Danz il 27 Mag 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.

Più risposte (0)

Categorie

Scopri di più su Develop Apps Using App Designer in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by