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
  댓글 수: 2
Walter Roberson
Walter Roberson 2023년 5월 24일
Sure, just program a ValueChanging or ValueChanged callback and have the callback change the CData of the existing image object then drawnow()

댓글을 달려면 로그인하십시오.

답변 (1개)

prabhat kumar sharma
prabhat kumar sharma 2023년 11월 20일
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