I create a GUI with 2 axes.
The first axes I would like just to display an image. Code i used is as below:
I = imread('file destination')
imshow(I)
The second one I would like to plot something on it.
Then i create a button to reset the second axes to initial condition.
But when i press it,it erase everything on second axes and the initial condition was set at first axes.
now the image on first axes was replace by the initial condition.
Anyone can help me?it's kinda urgent.
*the initial condition here is a 3D manipulator plot.

2 件のコメント

Chandra Kurniawan
Chandra Kurniawan 2011 年 12 月 17 日
Would you tell me the code you used to reset the axes??
Cheng Yoong
Cheng Yoong 2011 年 12 月 17 日
I've attached the GUI i've done so that you can get a clearer picture. You can download from here:
<<http://www.sendspace.com/file/gefazr>>
There are 2 axes that i've created. The smaller one i wish to display the robot.jpg which i've included in the folder.The bigger one is to plot the robot.But when execute it,the robot will plot at the smaller one.

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

 採用された回答

Chandra Kurniawan
Chandra Kurniawan 2011 年 12 月 17 日

2 投票

Hello,
I have modified your code :

16 件のコメント

Chandra Kurniawan
Chandra Kurniawan 2011 年 12 月 17 日
Hi,
Sorry before. I have deleted comments in your code.
Cheng Yoong
Cheng Yoong 2011 年 12 月 17 日
Thanks man!
Do u familiar with robotic?
I wana modified the robot appearance but i dont have any idea.
Chandra Kurniawan
Chandra Kurniawan 2011 年 12 月 17 日
Not many :(
But I'll help you to implement your ideas in Matlab ;)
Cheng Yoong
Cheng Yoong 2011 年 12 月 17 日
that's help alot.
basically i just want to modify the graphic.No much related to robotic i think.
As u can see,I use sticks to represent robot link.
How can I modify it to cylinder instead of stick?
Chandra Kurniawan
Chandra Kurniawan 2011 年 12 月 17 日
Yes, you can do experiment with 'cylinder'.
Try to see help for 'cylinder', how to surf it on 3D axes.
Something like this :
[X Y Z] = cylinder(10);
surf(X,Y,Z);
axis square
Cheng Yoong
Cheng Yoong 2011 年 12 月 17 日
I've tried that before.
Something i'm not really understand about the [X Y Z].
Is XYZ represent the starting point of the cylinder?
Let's say I have point1(x1,y1,z1) and point2(x2,y2,z2),how can i plot the cylinder from point1 to point2?
Chandra Kurniawan
Chandra Kurniawan 2011 年 12 月 17 日
The first time I learned this thing, I also get little confussed.
But if you try to do small experiment with it, you'll get the point.
Eq : I can control the length, the X position or Y position.
Have you tried this?
[X Y Z] = cylinder(1);
Z = 10*Z;
surf(X,Y,Z);
axis([-10 10 -10 10 -10 10]);
Cheng Yoong
Cheng Yoong 2011 年 12 月 17 日
I've tried that as well before this when I do some research for cylinder.But it cant help me to manipulate the cylinder as I want.
Because inside the GUI,the cylinder have to move in different direction,depend on the user. So,i'm thinking using the concept between 2 points to manipulate it.
Chandra Kurniawan
Chandra Kurniawan 2011 年 12 月 17 日
Yes, I got a trouble when try to surf it from one point to other point like you said.
I have no idea, but I just try to plot from one point and then rotate it closer to the second point.
Cheng Yoong
Cheng Yoong 2011 年 12 月 17 日
How to rotate it?
Chandra Kurniawan
Chandra Kurniawan 2011 年 12 月 17 日
I just use this code to rotate the object
[X Y Z] = cylinder(1);
Z = 10*Z;
h=surf(X,Y,Z);
rotate(h,[1 0 0],45)
axis([-10 10 -10 10 -10 10]);
Chandra Kurniawan
Chandra Kurniawan 2011 年 12 月 17 日
[X Y Z] = cylinder(1);
Z = 10*Z;
h=surf(X,Y,Z);
axis([-10 10 -10 10 -10 10]);
crt = 1
while crt == 1
rotate(h,[1 0 0],10)
drawnow;
pause(0.1);
end
Cheng Yoong
Cheng Yoong 2011 年 12 月 17 日
what is crt?
and this line
rotate(h,[1 0 0],10)
what is [1 0 0]?
Chandra Kurniawan
Chandra Kurniawan 2011 年 12 月 17 日
crt was created to do infinite loop in line 'while crt==1'
and
rotate(h,[1 0 0],10) means
h = object handle
[1 0 0] = direction of rotation, as we know [x y z]
10 = alpha degrees, you rotate the object 10 degrees
Cheng Yoong
Cheng Yoong 2011 年 12 月 17 日
That might help me.
I notice that the cylinder always started from point(0,0,0).
is that anywhere to change that?
Chandra Kurniawan
Chandra Kurniawan 2011 年 12 月 17 日
Of course you can.
You can do modification on X Y Z values
Eq :
[X Y Z] = cylinder(1);
Z = 10*Z;
X = X-20;
Y = Y-5;
h=surf(X,Y,Z);
axis([-10 10 -10 10 -10 10]);

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

その他の回答 (3 件)

Image Analyst
Image Analyst 2011 年 12 月 17 日

0 投票

The pushbutton to clear the second axes should just look something like
axes(handles.axes2); % Do this immmediately upon entering callback function
cla reset;
If it doesn't mention anything about handles.axes1 after you set the current axes to #2 then it will not do anything to axes #1.
Walter Roberson
Walter Roberson 2011 年 12 月 17 日

0 投票

My recommendation is to specifically parent all graphics activity. I give an example here, which also has a link to a post in which I explain why it is important.

1 件のコメント

Cheng Yoong
Cheng Yoong 2011 年 12 月 17 日
i saw one of your example has the following codes:
f = figure();
ax = axes('Parent',f);
but the defined 'f' is to plot on a pop out axes.
if now i already have an axes in my GUI(tag with axes1), how am i going to define the 'f'?

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

GANESH RATHOD
GANESH RATHOD 2017 年 11 月 11 日

0 投票

for n = 1:3
if n==1;
axes(handles.axes1);
hold off;
cla reset;
elseif n==2;
axes(handles.axes2);
hold off;
cla reset;
else
axes(handles.axes3);
hold off;
cla reset;
end;
end;

カテゴリ

ヘルプ センター および File ExchangeGraphics Performance についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by