How to move a picture in GUI corresponds to user input speed?

3 ビュー (過去 30 日間)
Waaaaa
Waaaaa 2017 年 7 月 26 日
コメント済み: Waaaaa 2017 年 8 月 3 日
In my GUI, I want a .jpg picture to be able to move along either horizontal or vertical direction. The speed of moving would be a user input value. How can I do that? Thanks!

採用された回答

Akhilesh Thakur
Akhilesh Thakur 2017 年 7 月 26 日
There are many ways to approach this.
First get the position of your GUI f = figure('Position',[300 300 300 200]);
Set the desired position you want
set(handles.figure_main,'Units', 'pixels');
set(handles.figure_main,'Position', [900 39 912 600]);
If you want to move the gui in horizontal and vertical direction you can set it in for loop and enter the desired values you want to increment. For eg you want to move horizontal from 0 to 100. Put these values in temp variable and increment it by one. Regarding speed I'm not sure what exactly u meant. But if you want user to change the speed then you can a put a pause(a); in for loop. Where a would the delay before updating to new position. So if a is very less like 0.1. It will update its position fast and if a is 1 then it will be slow. This method will give overall control of the speed.
  3 件のコメント
Akhilesh Thakur
Akhilesh Thakur 2017 年 7 月 27 日
Yes you can. Sure, if you need anything let me know.
Waaaaa
Waaaaa 2017 年 8 月 3 日
Hello again. How can I turn the image while it's moving straight without shrinking the image size? If my image is a car, then I want it to be able to turn right or left. Right now, I am using view(,) to rotate the image. However, the image shrinks while its rotating....
Thank you so much for your help!

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by