Joint angle values are changing from an initial to a final value with constant velocity in a given time(Given as a loop function). I have to plot a graph of joint angle motion?

I have to plot a graph of joint angle motion from initial to final value by considering every values assumed by the joint . How it is possible?Any help will be usefull.

5 Comments

Can you give an example what are you trying to do? The information is insufficient. Attach code or image to further elaborate your point,
L1 = 20 ;L2 = 16;L3 = 12; d1 = 2;d2 = 2; L(1)= Link([0 d1 0 pi/2]);
L(2)= Link([0 0 L1 0]);
L(3)= Link([0 0 L2 0]);
L(4)= Link([0 0 L3 pi/2]);
L(5)= Link([0 d2 0 0]);
Rob = SerialLink (L);
Rob.name= 'Robot';
figure(1)
Rob.plot([0 0 0 0 0]);
q1=0; q2=0; q3=0; q4=0; q5=0;
q1f=pi/2; q2f=pi/4; q3f=pi/4; q4f=pi/2; q5f=pi/2;
time = 10;
for t = 0:0.7:time;
k1=q1+(q1f-q1)*(t/time);
k2=q2+(q2f-q2)*(t/time);
k3=q3+(q3f-q3)*(t/time);
k4=q4+(q4f-q4)*(t/time);
k5=q5+(q5f-q5)*(t/time);
figure(2)
pause(0.1);
Rob.plot([k1,k2,k3,k4,k5]);
figure(3)
tx = linspace(0,20);
plot(tx,k1);hold on
title('Joint 1')
end
This is the code
I don't have variable names Link used in your code. Also, can you explain the problem you are facing?
I want to plot all the values from initial to final assumed by the joint in a single graph. Those values are obtained from this loop . But when I try to plot it inside the loop, several graphs are coming.If plotted outside ,only initial and final values are plotted in graph..
from this code, I can't say what does rob.plot do, but hold on should prevent the old graphics objects from being deleted.

Sign in to comment.

Answers (1)

Please take a look at
doc refreshdata
This will allow you to specify a data source for your plot outside of the loop and update it inside.

2 Comments

I have tried this sir.But I am plotting the graph of time versus joint position with constant velocity , the graph should consists several diagonal lines . Isn't it? But I am getting graph like this??
Ah I think I have misunderstood your question, I thought you were trying to make an animated graph. Basically you want to plot position as function of time for 5 velocities, right? Something equivalent to this should work:
% time and velocity
t = 0:10;
v = 1:5;
% preallocate x
x = zeros(5, 11);
% find x in a loop
for i = 1:5
x(i, :) = v(i)*t;
end
% plot
plot(x, t)

Sign in to comment.

Asked:

on 4 May 2018

Commented:

on 5 May 2018

Community Treasure Hunt

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

Start Hunting!