App designer - resizing axes to image size

34 Ansichten (letzte 30 Tage)
Teshan Rezel
Teshan Rezel am 18 Mär. 2021
Kommentiert: Rashed Mohammed am 23 Mär. 2021
Hi folks,
I'm displaying a JPEG image in my app and currently, the axes stretch the image when the window is maximised. Is there a way to make the axes the same size as the image, so that it doesn't stretch the image to maximise the window?
Thanks

Akzeptierte Antwort

Rashed Mohammed
Rashed Mohammed am 22 Mär. 2021
Hi Teshan,
Since you have mentioned axes, I'm assuming you are using uiaxes to display the image. However, MATLAB has uiimage function for displaying images inside applications. This function also has the Name-Value pair ScaleMethod giving users the control over how the image must be displayed when the component area changes.
Hope this helps
  2 Kommentare
Teshan Rezel
Teshan Rezel am 22 Mär. 2021
Thanks Rashed, is there a way to incorporate this using the App designer, since I only see the option to include a uiFigure or uiAxes there?
Rashed Mohammed
Rashed Mohammed am 23 Mär. 2021
In the App designer component library, there is an Image component which can be used in the Design View tab. You can access the ScaleMethod property once the image component is present in the component area. Alternatively you can use the following code in the Code View
img = uiimage(app.UIFigure,'ScaleMethod','none','ImageSource','image.jpg')
Hope this helps

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Produkte


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by