Add a slider to function in matlab

5 ビュー (過去 30 日間)
Zachary Tochka
Zachary Tochka 2013 年 9 月 13 日
Hey guys,
So I'm pretty new to programming GUIs and I had a question regarding how to add a slider to my function.
So the function I have is called rotationmatrix where the program rotates a 2D plot about the origin and saves the new x and y values for the rotated plot. I want to put a slider in to be able to change the angle of rotation on the plot without having to constantly input the angle into the M-file. I would also want the plot to change in real time as I move the slider. Could someone tell me how to do this? I really need your guys help!

回答 (3 件)

Sean de Wolski
Sean de Wolski 2013 年 9 月 13 日
Why not just use rotate3d on?
rotate3d on
Now you can move it with the mouse. If you're building it in GUIDE then add this button on the toolbar editor:
tools -> toolbar editor -> double click the rotation one

Zachary Tochka
Zachary Tochka 2013 年 9 月 13 日
I want to be able to save the rotated x-y coordinates to do some manipulation on the new x-y dataset so I don't think rotate3d would save the x,y variables, it would only save the figure.
  1 件のコメント
Sean de Wolski
Sean de Wolski 2013 年 9 月 13 日
Huh? Even if you save the figure, the x and y data will be saved as proeprties of the line.
Also, you can query x limits, y limits, and view azimuth and elevation using:
doc xlim
doc ylim
doc view
For example to get the view after rotating:
[az,el] = view

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


Zachary Tochka
Zachary Tochka 2013 年 9 月 13 日
編集済み: Zachary Tochka 2013 年 9 月 13 日
I don't understand. Say I have a data set where x = [1 2 3] and y = [4 4 4]. Then I want to rotate the figure 90 degrees to the right so that x becomes [4 4 4] and y becomes [1 2 3]. How do I save the figure so that I get the new x,y coordinates that have x =[4 4 4] and y =[1 2 3]?
When I mean save the figure I mean that I want to save the x,y variables to their new values.
  2 件のコメント
Sean de Wolski
Sean de Wolski 2013 年 9 月 13 日
But the values aren't changing! Just the way you're viewing them. Which is why it would be better to store the viewing angle.
Sean de Wolski
Sean de Wolski 2013 年 9 月 13 日
Otherwise you're going to need to calculate how the angle has changed and prioject your original x/y data into this new position. I think there is probably a better approach to do what you are trying to do.
What is the big picture?

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

カテゴリ

Help Center および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by