level 2
jed303542156
楼主
clear;
ls=800; % 定杆长
l=270;
t=0;
hhs1=[];
hhs2=[];
hhs3=[];
mm=[];
for alf=0:5:360
t=t+1;
z=0;
beta=45; r=150; R=450;
beta=beta*pi/180; alf=alf*pi/180;
x=r*(cos(beta)-1)*cos(2*alf)/2; % 由alf,beta 确定的动平台中心点坐标
y=r*(1-cos(beta))*sin(2*alf)/2;
p0=[x;y;z];
prsd=[R -R/2 -R/2
0 sqrt(3)*R/2 -sqrt(3)*R/2
0 0 0 ];
prsx=[r -r/2 -r/2
0 sqrt(3)*r/2 -sqrt(3)*r/2
0 0 0 ];
rot1=[cos(alf) -sin(alf) 0
sin(alf) cos(alf) 0
0 0 1 ];
rot2=[cos(beta) 0 sin(beta)
0 1 0
-sin(beta) 0 cos(beta)];
rot3=[cos(-alf) -sin(-alf) 0
sin(-alf) cos(-alf) 0
0 0 1 ];
rot=rot1*rot2*rot3;
p1=((prsx(:,1))'*rot)'+p0; p2=((prsx(:,2))'*rot)'+p0; p3=((prsx(:,3))'*rot)'+p0;
hs(1)=p1(3)+sqrt(ls^2-(R-p1(1))^2)-sqrt(ls^2-(R-r)^2);
hs(2)=p2(3)+sqrt(ls^2-((-R/2-p2(1))^2+(sqrt(3)*R/2-p2(2))^2))-sqrt(ls^2-(R-r)^2);
hs(3)=p3(3)+sqrt(ls^2-((-R/2-p3(1))^2+(-sqrt(3)*R/2-p3(2))^2))-sqrt(ls^2-(R-r)^2);
hhs1=[hhs1,hs(1)];
hhs2=[hhs2,hs(2)];
hhs3=[hhs3,hs(3)];
end
plot([1:t],hhs1,'r.',[1:t],hhs2,'k.',[1:t],hhs3,'g.')
以上是我的程序
我的问题是:现在输出的hhs的值都是对应 t 时刻的,但是我想要它输出 当前时刻 与 上一时刻 的hhs的差值,最后在用这些差值做一个图。我的这个想法如何实现?
2012年04月30日 13点04分
1
ls=800; % 定杆长
l=270;
t=0;
hhs1=[];
hhs2=[];
hhs3=[];
mm=[];
for alf=0:5:360
t=t+1;
z=0;
beta=45; r=150; R=450;
beta=beta*pi/180; alf=alf*pi/180;
x=r*(cos(beta)-1)*cos(2*alf)/2; % 由alf,beta 确定的动平台中心点坐标
y=r*(1-cos(beta))*sin(2*alf)/2;
p0=[x;y;z];
prsd=[R -R/2 -R/2
0 sqrt(3)*R/2 -sqrt(3)*R/2
0 0 0 ];
prsx=[r -r/2 -r/2
0 sqrt(3)*r/2 -sqrt(3)*r/2
0 0 0 ];
rot1=[cos(alf) -sin(alf) 0
sin(alf) cos(alf) 0
0 0 1 ];
rot2=[cos(beta) 0 sin(beta)
0 1 0
-sin(beta) 0 cos(beta)];
rot3=[cos(-alf) -sin(-alf) 0
sin(-alf) cos(-alf) 0
0 0 1 ];
rot=rot1*rot2*rot3;
p1=((prsx(:,1))'*rot)'+p0; p2=((prsx(:,2))'*rot)'+p0; p3=((prsx(:,3))'*rot)'+p0;
hs(1)=p1(3)+sqrt(ls^2-(R-p1(1))^2)-sqrt(ls^2-(R-r)^2);
hs(2)=p2(3)+sqrt(ls^2-((-R/2-p2(1))^2+(sqrt(3)*R/2-p2(2))^2))-sqrt(ls^2-(R-r)^2);
hs(3)=p3(3)+sqrt(ls^2-((-R/2-p3(1))^2+(-sqrt(3)*R/2-p3(2))^2))-sqrt(ls^2-(R-r)^2);
hhs1=[hhs1,hs(1)];
hhs2=[hhs2,hs(2)];
hhs3=[hhs3,hs(3)];
end
plot([1:t],hhs1,'r.',[1:t],hhs2,'k.',[1:t],hhs3,'g.')
以上是我的程序
我的问题是:现在输出的hhs的值都是对应 t 时刻的,但是我想要它输出 当前时刻 与 上一时刻 的hhs的差值,最后在用这些差值做一个图。我的这个想法如何实现?