Displaying a dynamic image that changes with programming into the MATLAB app designer. Is it possible/what functions would I need?

18 次查看(过去 30 天)
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

回答(1 个)

prabhat kumar sharma
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!

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by