Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
plot3d convers to plot3d in GUI

Subject: plot3d convers to plot3d in GUI

From: wahyoe Unggul

Date: 13 May, 2011 13:01:05

Message: 1 of 11

hi all
I plot 3d an object in the form of ordinary plot

figure('Name','undeformed structure.....
for i=1:(length(Support(:,1)));
plot3([X(i)+circlesize*2,X(i)-circlesize*2],-[Z(i),Z(i)],[Y(i),Y(i)],'r'); %line
plot3(sin(0:0.1:pi*2)*circlesize/2+X(i),cos(0:0.1:pi*2)*Z(i),cos(0:0.1:pi*2)*circlesize/2-circlesize/2+Y(i),'r') %circle

objects formed lines and circles of proportion, but if I move to a GUI
axis([min(MinX)-margin, max(MaxX)+margin, min(MinY)-margin, max(MaxY)+margin, min(MinZ)-margin, max(MaxZ)+margin])
                axislimits=axis;
                circlesize=max([axislimits(2)-axislimits(1),axislimits(4)-axislimits(3),axislimits(6)-axislimits(5)])/40
plot3([X(i)+circlesize*2,X(i)-circlesize*2],-[Z(i),Z(i)],[Y(i),Y(i)],'r'); % line
                plot3(sin(0:0.1:pi*2)*circlesize/2+X(i),cos(0:0.1:pi*2)*Z(i),cos(0:0.1:pi*2)*circlesize/2-circlesize/2+Y(i),'r')%circle

to object to the line but still the proportion of objects was not proportion circle again, about whether the factors that cause differences in the results of the 3d plot.

thanks
wahyoe
 

Subject: plot3d convers to plot3d in GUI

From: Steven_Lord

Date: 13 May, 2011 13:25:01

Message: 2 of 11



"wahyoe Unggul" <wahyoe_slipnot@yahoo.co.id> wrote in message
news:iqja2h$f42$1@newscl01ah.mathworks.com...
> hi all
> I plot 3d an object in the form of ordinary plot
>
> figure('Name','undeformed structure.....
> for i=1:(length(Support(:,1)));
> plot3([X(i)+circlesize*2,X(i)-circlesize*2],-[Z(i),Z(i)],[Y(i),Y(i)],'r');
> %line
> plot3(sin(0:0.1:pi*2)*circlesize/2+X(i),cos(0:0.1:pi*2)*Z(i),cos(0:0.1:pi*2)*circlesize/2-circlesize/2+Y(i),'r')
> %circle
> objects formed lines and circles of proportion, but if I move to a GUI
> axis([min(MinX)-margin, max(MaxX)+margin, min(MinY)-margin,
> max(MaxY)+margin, min(MinZ)-margin, max(MaxZ)+margin])
> axislimits=axis;
>
> circlesize=max([axislimits(2)-axislimits(1),axislimits(4)-axislimits(3),axislimits(6)-axislimits(5)])/40
> plot3([X(i)+circlesize*2,X(i)-circlesize*2],-[Z(i),Z(i)],[Y(i),Y(i)],'r');
> % line
>
> plot3(sin(0:0.1:pi*2)*circlesize/2+X(i),cos(0:0.1:pi*2)*Z(i),cos(0:0.1:pi*2)*circlesize/2-circlesize/2+Y(i),'r')%circle
>
> to object to the line but still the proportion of objects was not
> proportion circle again, about whether the factors that cause differences
> in the results of the 3d plot.

Look at the help for the AXIS command. I believe what you're looking to do
is "axis equal".

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: plot3d convers to plot3d in GUI

From: wahyoe Unggul

Date: 13 May, 2011 14:16:02

Message: 3 of 11


> Look at the help for the AXIS command. I believe what you're looking to do
> is "axis equal".
>
> --
> Steve Lord
> slord@mathworks.com
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com

hai lord
I've tried but the results are also similar

Subject: plot3d convers to plot3d in GUI

From: Steven_Lord

Date: 13 May, 2011 16:00:12

Message: 4 of 11



"wahyoe Unggul" <wahyoe_slipnot@yahoo.co.id> wrote in message
news:iqjef2$10$1@newscl01ah.mathworks.com...
>
>> Look at the help for the AXIS command. I believe what you're looking to
>> do is "axis equal".
>>
>> --
>> Steve Lord
>> slord@mathworks.com
>> To contact Technical Support use the Contact Us link on
>> http://www.mathworks.com
>
> hai lord
> I've tried but the results are also similar

I can has picture of the non-GUI and GUI axes? [Sorry. Your use of "hai"
reminded me of "I Can Has Cheezburger?" (http://icanhascheezburger.com/) so
I wanted to have a little fun.]

Seriously, please print the GUI and the non-GUI axes to image files, put
them on an image hosting site, and post links to those files in your reply
so the group can see the differences that you're seeing.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: plot3d convers to plot3d in GUI

From: wahyoe Unggul

Date: 13 May, 2011 17:40:20

Message: 5 of 11


> Seriously, please print the GUI and the non-GUI axes to image files, put
> them on an image hosting site, and post links to those files in your reply
> so the group can see the differences that you're seeing.
>
> --
> Steve Lord
> slord@mathworks.com
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com
 

http://s1176.photobucket.com/albums/x329/wahyoe2/?action=view¤t=untitled.jpg

axes (handles.draw)
axis equal
for i=1:(length(Support(:,1)));
plot3([X(i)+circlesize*2,X(i)-circlesize*2],-[Z(i),Z(i)],[Y(i),Y(i)],'r');
                plot3(sin(0:0.1:pi*2)*circlesize/2+X(i),cos(0:0.1:pi*2)*Z(i),cos(0:0.1:pi*2)*circlesize/2-circlesize/2+Y(i),'r')
                plot3(sin(0:0.1:pi*2)*circlesize/2+X(i)+circlesize,cos(0:0.1:pi*2)*Z(i),cos(0:0.1:pi*2)*circlesize/2-circlesize/2+Y(i),'r')
                plot3(sin(0:0.1:pi*2)*circlesize/2+X(i)-circlesize,cos(0:0.1:pi*2)*Z(i),cos(0:0.1:pi*2)*circlesize/2-circlesize/2+Y(i),'r')
 
  because the script is too long, can I send the file to your email? and then mistakes can be posted

Subject: plot3d convers to plot3d in GUI

From: wahyoe Unggul

Date: 13 May, 2011 17:53:05

Message: 6 of 11

> Seriously, please print the GUI and the non-GUI axes to image files, put
> them on an image hosting site, and post links to those files in your reply
> so the group can see the differences that you're seeing.
>
> --
> Steve Lord
> slord@mathworks.com
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com
 

http://s1176.photobucket.com/albums/x329/wahyoe2/?action=view¤t=untitled.jpg

axes (handles.draw)
axis equal
for i=1:(length(Support(:,1)));
plot3([X(i)+circlesize*2,X(i)-circlesize*2],-[Z(i),Z(i)],[Y(i),Y(i)],'r');
                plot3(sin(0:0.1:pi*2)*circlesize/2+X(i),cos(0:0.1:pi*2)*Z(i),cos(0:0.1:pi*2)*circlesize/2-circlesize/2+Y(i),'r')
                plot3(sin(0:0.1:pi*2)*circlesize/2+X(i)+circlesize,cos(0:0.1:pi*2)*Z(i),cos(0:0.1:pi*2)*circlesize/2-circlesize/2+Y(i),'r')
                plot3(sin(0:0.1:pi*2)*circlesize/2+X(i)-circlesize,cos(0:0.1:pi*2)*Z(i),cos(0:0.1:pi*2)*circlesize/2-circlesize/2+Y(i),'r')
 
  because the script is too long, can I send the file to your email? and then mistakes can be posted

Subject: plot3d convers to plot3d in GUI

From: Steven_Lord

Date: 13 May, 2011 18:45:33

Message: 7 of 11



"wahyoe Unggul" <wahyoe_slipnot@yahoo.co.id> wrote in message
news:iqjqe4$b9h$1@newscl01ah.mathworks.com...
>
>> Seriously, please print the GUI and the non-GUI axes to image files, put
>> them on an image hosting site, and post links to those files in your
>> reply so the group can see the differences that you're seeing.
>>
>> --
>> Steve Lord
>> slord@mathworks.com
>> To contact Technical Support use the Contact Us link on
>> http://www.mathworks.com
>
>
> http://s1176.photobucket.com/albums/x329/wahyoe2/?action=view¤t=untitled.jpg
>
> axes (handles.draw)
> axis equal
> for i=1:(length(Support(:,1)));
> plot3([X(i)+circlesize*2,X(i)-circlesize*2],-[Z(i),Z(i)],[Y(i),Y(i)],'r');
>
> plot3(sin(0:0.1:pi*2)*circlesize/2+X(i),cos(0:0.1:pi*2)*Z(i),cos(0:0.1:pi*2)*circlesize/2-circlesize/2+Y(i),'r')
>
> plot3(sin(0:0.1:pi*2)*circlesize/2+X(i)+circlesize,cos(0:0.1:pi*2)*Z(i),cos(0:0.1:pi*2)*circlesize/2-circlesize/2+Y(i),'r')
>
> plot3(sin(0:0.1:pi*2)*circlesize/2+X(i)-circlesize,cos(0:0.1:pi*2)*Z(i),cos(0:0.1:pi*2)*circlesize/2-circlesize/2+Y(i),'r')
>
> because the script is too long, can I send the file to your email? and
> then mistakes can be posted

No. Please post the script here so that others can see it and offer
suggestions as well. But before posting a really long script, see if you can
come up with a shorter script that shows the same general behavior.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: plot3d convers to plot3d in GUI

From: Alan Jennings

Date: 13 May, 2011 19:35:05

Message: 8 of 11

I'm not sure exactly what your trying to do, but 'axis equal' has caused problems for me a number of times, so I use daspect([1,1,1]), or daspect([1,1,1/5]) if the z scale needs to be streached.
Taking a quick guess, if you're working in a GUI, you might be getting a different axis than you think you are. Try some basic commands like changing the tick markers, or turning them on and off, to see if you do have the right set when you're setting/getting.
Hope this helps, Alan J.

Subject: plot3d convers to plot3d in GUI

From: wahyoe Unggul

Date: 13 May, 2011 19:39:05

Message: 9 of 11


> No. Please post the script here so that others can see it and offer
> suggestions as well. But before posting a really long script, see if you can
> come up with a shorter script that shows the same general behavior.
>
> --
> Steve Lord
> slord@mathworks.com
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com
 
% coord file
 1 0 0 4242.6
2 4242.6 0 4242.6
 3 4242.6 0 0
 4 0 0 0
 5 2121.3 4000 2121.3

% element file
1 1 5 1 0
         2 2 5 2 0
         3 3 5 3 0
4 4 5 4 0

% Support file
1 0 1 0
2 0 1 0
3 0 1 0
4 0 1 0

GUI
function coordinat_Callback(hObject, eventdata, handles)
coord=uigetfileuigetfile({'*.txt'}) % input coord file
set(hObject,'Userdata',coord)

function element_Callback(hObject, eventdata, handles)
element=uigetfileuigetfile({'*.txt'}) % input element file
set(hObject,'Userdata',element)

function Support_Callback(hObject, eventdata, handles)
Support=uigetfileuigetfile({'*.txt'}) % input element file
set(hObject,'Userdata',Support)

coord=get(handles.coordinat,'UserData');
                element=get(handles.element,'UserData');
                [AX,AY,AZ,circlesize,...
                spasi,Xsupport,Ysupport,Zsupport]=undeformedt3d( coord,...
                element,Support );
                typesupport=[Support(:,2) Support(:,3) Support(:,4)];
                
                
                 axes (handles.draw)
                 axis equal
                 for i=1:(length(element(:,1)));
                      hold on
                      plot3 (AX(i,:),AZ(i,:),AY(i,:),'-g.','LineWidth',1);
                  end
                  
                for i=1:(length(Support(:,1)));
                    if typesupport(i,:)==[1 1 1]
                       plot3([Xsupport(i),Xsupport(i)-circlesize,Xsupport(i)+circlesize,Xsupport(i)],...
                       -[Zsupport(i),Zsupport(i),Zsupport(i),Zsupport(i)],...
                        [Ysupport(i),Ysupport(i)-circlesize,Ysupport(i)-circlesize,Ysupport(i)],'r')
                    elseif typesupport(i,:)==[0 1 0]
                       plot3([Xsupport(i)+circlesize*2,Xsupport(i)-circlesize*2],-[Zsupport(i),Zsupport(i)],[Ysupport(i),Ysupport(i)],'r');
                       plot3(sin(0:0.1:pi*2)*circlesize/2+Xsupport(i),cos(0:0.1:pi*2)*Zsupport(i),cos(0:0.1:pi*2)*circlesize/2-circlesize/2+Ysupport(i),'r')
                    else
                     
                    end
                end


% function file
function [AX,AY,AZ,MaxX,MinX,MinY,MaxY,MinZ,MaxZ,circlesize,...
    spasi,Xsupport,Ysupport,Zsupport]=undeformedt3d( coord,...
    element,Support )
Joint=coord(:,1);
m=size(element,1);
Xj=zeros(1,m);
Xk=Xj;
Yj=Xj;
Yk=Xj;
Zj=Xj;
Zk=Xj;
% Matriks Xj, Xy, Yj, Yk, Zj dan Zk
for i=1:m
    ij=find(Joint==element(i,2));
    ik=find(Joint==element(i,3));
    Xj(i)=coord(ij,2);
    Xk(i)=coord(ik,2);
    Yj(i)=coord(ij,3);
    Yk(i)=coord(ik,3);
    Zj(i)=coord(ij,4);
    Zk(i)=coord(ik,4);
end


AX=[Xj' Xk'];
AY=[Yj' Yk'];
AZ =-[Zj' Zk'];

MinX=min([Xj Xk Xj]);
MaxX=max([Xj Xk Xk]);
MinY=min([Yj Yk Yj]);
MaxY=max([Yj Yk Yk]);
MinZ=min([Zj Zk Zj]);
MaxZ=max([Zj Zk Zk]);

spasi=0.1*max([MaxX-MinX MaxY-MinY MaxZ-MinZ]);
circlesize=0.05*max([MaxX-MinX MaxY-MinY MaxZ-MinZ]);


typesupport=([Support(:,2) Support(:,3) Support(:,4)])
pos_support=([coord(Support(:,1),2) coord(Support(:,1),3) coord(Support(:,1),4)]);
Xsupport=pos_support(:,1);
Ysupport=pos_support(:,2);
Zsupport=pos_support(:,3);

Subject: plot3d convers to plot3d in GUI

From: wahyoe Unggul

Date: 13 May, 2011 19:40:20

Message: 10 of 11


> No. Please post the script here so that others can see it and offer
> suggestions as well. But before posting a really long script, see if you can
> come up with a shorter script that shows the same general behavior.
>
> --
> Steve Lord
> slord@mathworks.com
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com
 
% coord file
 1 0 0 4242.6
2 4242.6 0 4242.6
 3 4242.6 0 0
 4 0 0 0
 5 2121.3 4000 2121.3

% element file
1 1 5 1 0
         2 2 5 2 0
         3 3 5 3 0
4 4 5 4 0

% Support file
1 0 1 0
2 0 1 0
3 0 1 0
4 0 1 0

GUI
function coordinat_Callback(hObject, eventdata, handles)
coord=uigetfileuigetfile({'*.txt'}) % input coord file
set(hObject,'Userdata',coord)

function element_Callback(hObject, eventdata, handles)
element=uigetfileuigetfile({'*.txt'}) % input element file
set(hObject,'Userdata',element)

function Support_Callback(hObject, eventdata, handles)
Support=uigetfileuigetfile({'*.txt'}) % input element file
set(hObject,'Userdata',Support)

coord=get(handles.coordinat,'UserData');
                element=get(handles.element,'UserData');
                [AX,AY,AZ,circlesize,...
                spasi,Xsupport,Ysupport,Zsupport]=undeformedt3d( coord,...
                element,Support );
                typesupport=[Support(:,2) Support(:,3) Support(:,4)];
                
                
                 axes (handles.draw)
                 axis equal
                 for i=1:(length(element(:,1)));
                      hold on
                      plot3 (AX(i,:),AZ(i,:),AY(i,:),'-g.','LineWidth',1);
                  end
                  
                for i=1:(length(Support(:,1)));
                    if typesupport(i,:)==[1 1 1]
                       plot3([Xsupport(i),Xsupport(i)-circlesize,Xsupport(i)+circlesize,Xsupport(i)],...
                       -[Zsupport(i),Zsupport(i),Zsupport(i),Zsupport(i)],...
                        [Ysupport(i),Ysupport(i)-circlesize,Ysupport(i)-circlesize,Ysupport(i)],'r')
                    elseif typesupport(i,:)==[0 1 0]
                       plot3([Xsupport(i)+circlesize*2,Xsupport(i)-circlesize*2],-[Zsupport(i),Zsupport(i)],[Ysupport(i),Ysupport(i)],'r');
                       plot3(sin(0:0.1:pi*2)*circlesize/2+Xsupport(i),cos(0:0.1:pi*2)*Zsupport(i),cos(0:0.1:pi*2)*circlesize/2-circlesize/2+Ysupport(i),'r')
                    else
                     
                    end
                end


% function file
function [AX,AY,AZ,MaxX,MinX,MinY,MaxY,MinZ,MaxZ,circlesize,...
    spasi,Xsupport,Ysupport,Zsupport]=undeformedt3d( coord,...
    element,Support )
Joint=coord(:,1);
m=size(element,1);
Xj=zeros(1,m);
Xk=Xj;
Yj=Xj;
Yk=Xj;
Zj=Xj;
Zk=Xj;
% Matriks Xj, Xy, Yj, Yk, Zj dan Zk
for i=1:m
    ij=find(Joint==element(i,2));
    ik=find(Joint==element(i,3));
    Xj(i)=coord(ij,2);
    Xk(i)=coord(ik,2);
    Yj(i)=coord(ij,3);
    Yk(i)=coord(ik,3);
    Zj(i)=coord(ij,4);
    Zk(i)=coord(ik,4);
end


AX=[Xj' Xk'];
AY=[Yj' Yk'];
AZ =-[Zj' Zk'];

MinX=min([Xj Xk Xj]);
MaxX=max([Xj Xk Xk]);
MinY=min([Yj Yk Yj]);
MaxY=max([Yj Yk Yk]);
MinZ=min([Zj Zk Zj]);
MaxZ=max([Zj Zk Zk]);

spasi=0.1*max([MaxX-MinX MaxY-MinY MaxZ-MinZ]);
circlesize=0.05*max([MaxX-MinX MaxY-MinY MaxZ-MinZ]);


typesupport=([Support(:,2) Support(:,3) Support(:,4)])
pos_support=([coord(Support(:,1),2) coord(Support(:,1),3) coord(Support(:,1),4)]);
Xsupport=pos_support(:,1);
Ysupport=pos_support(:,2);
Zsupport=pos_support(:,3);

Subject: plot3d convers to plot3d in GUI

From: wahyoe Unggul

Date: 13 May, 2011 19:53:04

Message: 11 of 11

"Alan Jennings" wrote in message <iqk159$7m4$1@newscl01ah.mathworks.com>...
> I'm not sure exactly what your trying to do, but 'axis equal' has caused problems for me a number of times, so I use daspect([1,1,1]), or daspect([1,1,1/5]) if the z scale needs to be streached.
> Taking a quick guess, if you're working in a GUI, you might be getting a different axis than you think you are. Try some basic commands like changing the tick markers, or turning them on and off, to see if you do have the right set when you're setting/getting.
> Hope this helps, Alan J.

I several times to change the axis, but the results are also similar
wahyoe

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us