How to plot vectors of different length
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Star Strider
le 4 Oct 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 commentaires
Voir également
Catégories
En savoir plus sur Numerical Integration and Differential Equations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!