2011-04-14 8 views
1

로봇 위치 방정식과 그래프를 표시하는 명령을 작성하고 싶습니다. 이 내 명령이지만, 그래프 표시되지 않았습니다 : 플롯에 의해로봇 조인트 그래프의 플로팅 위치가 작동하지 않습니다.

clear; 
clc; 

% initial position 
theta1s=-150; 
theta2s=-80; 
theta3s=-50; 
theta4s=-100; 
theta5s=-180; 

% final position 
theta1f=20; 
theta2f=100; 
theta3f=80; 
theta4f=50; 
theta5f=180; 

% time taken for movement 
tf=input('time=') 

% acceleration for every link 
acc1=(4.*(20-(-150)))./(tf^2) 
acc2=(4.*(100-(-80)))./(tf^2) 
acc3=(4.*(80-(-50)))./(tf^2) 
acc4=(4.*(50-(-100)))./(tf^2) 
acc5=(4.*(180-(-180)))./(tf^2) 

% blending time for every link 
tb1=((0.5.*(tf))-(0.5.*(sqrt((((tf^2).*acc1)-(4.*(20-(-150))))./acc1)))) 
t = 0; 
for x = 0:tf; 
    t = t + 0.1; 
    if 0<t<=tb1; 
     y = theta1s+((0.5.*acc1).*(t^2)); 
    elseif tb1<t<=tf-tb1; 
     y = (theta1s-((0.5.*acc1).*(tb1^2)))+(acc1.*tb1.*t); 
    else tf-tb1<t<=tf; 
     y = theta1s-((0.5.*acc1).*(tf.*t)^2); 
    end 

    plot(x,y,'r') 
    title('Position Versus Time'); 
    xlabel('time in s'); 
    ylabel('position in m'); 
    grid on; 
    drawnow; 
end 

disp(y); 

답변

1

당신은 대체 할 수있는 플롯 (X, Y, 'R')를 (X, Y, 'R *'). 그래서, 당신은 sepparate 포인트를 볼 수있을 것입니다. 또한 모든 반복에 대해 플롯을 오버레이 할 수 있도록 플롯 기능 후에 "대기"를 추가해야합니다.

선을 그리지 만 분리 점을 그리지 않으려면 루프 밖으로 시각화를 옮기는 것이 좋습니다. 참고로, 나 Y의 방정식을 표시하는 명령 DISP (Y)를 사용 돕는

clear; 
clc; 

% initial position 
theta1s=-150; 
theta2s=-80; 
theta3s=-50; 
theta4s=-100; 
theta5s=-180; 

% final position 
theta1f=20; 
theta2f=100; 
theta3f=80; 
theta4f=50; 
theta5f=180; 

% time taken for movement 
tf=input('time=') 

% acceleration for every link 
acc1=(4.*(20-(-150)))./(tf^2) 
acc2=(4.*(100-(-80)))./(tf^2) 
acc3=(4.*(80-(-50)))./(tf^2) 
acc4=(4.*(50-(-100)))./(tf^2) 
acc5=(4.*(180-(-180)))./(tf^2) 

% blending time for every link 
tb1=((0.5.*(tf))-(0.5.*(sqrt((((tf^2).*acc1)-(4.*(20-(-150))))./acc1)))) 
t = 0; 

% allocate memory for array 
y = zeros(1, tf+1); 

for x = 0:tf; 
    t = t + 0.1; 
    if 0<t<=tb1; 
     y(x+1) = theta1s+((0.5.*acc1).*(t^2)); 
    elseif tb1<t<=tf-tb1; 
     y(x+1) = (theta1s-((0.5.*acc1).*(tb1^2)))+(acc1.*tb1.*t); 
    else tf-tb1<t<=tf; 
     y(x+1) = theta1s-((0.5.*acc1).*(tf.*t)^2); 
    end 
end 

plot(0:tf,y,'r') 
title('Position Versus Time'); 
xlabel('time in s'); 
ylabel('position in m'); 
grid on; 
drawnow; 

disp(y); 
+0

감사 .. 다음은 수정 된 코드이다. 예 : 예 : y = -150 + 15t^2 y = -195.21 + 52.08t y = 20-15 (5-t)^2 그러나 방정식이 표시되지 않고 숫자 만 표시됩니다. -149.8640 -149.4560 -148.7760 -147.8240-146.6000 -145.1040 –

+0

matlab은 y를 벡터로 저장하지만 수식으로 저장하지 않습니다. 그래서 y에서 방정식을 복구 할 수 없습니다. 어쨌든 그것을 표시해야하는 경우 문자열로 표시해보십시오 : disp ('y = -150 + 15t^2') – user502144

관련 문제