How to plot vectors of different length
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
We were asked to plot the derivative of angular displacement to get the angular velocity, and the derivative of angular velocity to get the angular acceleration. I was able to calculate the derivative, but it will not allow me to plot the vectors because they are not the same length. Any suggestions on how to plot?
if true
M=csvread(filename, 2,0);
a=M(:,1); %time in seconds
b=M(:,2); %angular displacement
c=M(:,3); %angular velocity
d=M(:,4); %angular acceleration
plot(a,b,'r')
hold on
plot(a,c,'g')
hold on
plot(a,d,'b')
hold on
title('Raw Kinematics Data on Arm Flexion-Extension')
%Part b
figure
l=diff(b); %differentiates the angular velocity
n=diff(c); %differentiates the angular acceleration
plot(a,l)
hold on
plot(a,n)
end
0 comentarios
Respuestas (1)
Star Strider
el 4 de Oct. de 2018
The problem is that you are using the numerical diff function that produces outputs that are smaller than the inputs.
A much better solution is to use the gradient (link) function instead. It produces a numeric derivative the same size as the input, eliminating the problem of different-size vectors.
0 comentarios
Ver también
Categorías
Más información sobre Numerical Integration and Differential Equations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!