Displaying a dynamic image that changes with programming into the MATLAB app designer. Is it possible/what functions would I need?
18 views (last 30 days)
Show older comments
Is there a good way/capablility to display a changing image with a changing menu or selection in MATLAB App Designer. For example, in the app designer, if I change the scale of the image from a spinner, how do I get that change reflected in the image immeadietly upon selection, and how/what functions would I use to program the original image getting scaled. In other words, how do I program and display a dynamic image in MATLAB app designer, and does the app designer allow for this operation. Thanks
2 Comments
Walter Roberson
on 24 May 2023
Sure, just program a ValueChanging or ValueChanged callback and have the callback change the CData of the existing image object then drawnow()
Answers (1)
prabhat kumar sharma
on 20 Nov 2023
Hello Griffin,
I understand you are facing an issue with the immediate scaling of the image.
I will suggest you use a valueChanged Callback and in that callback, you can change the positions of the image according to the value of the spinner.
function SpinnerValueChanged(app, event)
value = app.Spinner.Value
app.Image.Position(3) = value %width of the image
app.Image.Position(4) = value %Height of the image
end
If you are looking to automatically update the width of the image and want to track the width updating immediately then you can use the 'drawnow'. You can refer to the below code, here I have tried to update the width in 1000 iterations using a loop.
function SpinnerValueChanged(app, event)
x = linspace(0,10,1000);
for k = 1:length(x)
app.Spinner.Value = k;
app.Image.Position(3) = k;
drawnow
end
end
To know more on 'drawnow' you can refer to the following documentation: https://www.mathworks.com/help/matlab/ref/drawnow.html
I hope it helps!
0 Comments
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!