Incorrect extreme values of numerical derivative

2 vues (au cours des 30 derniers jours)
Jørgen Tømmermo
Jørgen Tømmermo le 25 Nov 2020
Hi!
I get different plots from Matlab and SolidWorks. Can anyone check mye code/help with ideas? :)
Disclaimer: I can not guarantee my work in SolidWorks is correct.
Background:
This is part of a kinematic analasys of a mechanism. I am to do a numerical analasys of a point of interest and also simulate the mechanism (in my case in SolidWorks). My pont of interest has one-dimentional movement. I use Matlab to calculate the velocity of my point.
Problem:
The velocity (in regards to time) is very similar for SolidWorks and Matlab.
The acceleration plot however is what i am struggelig with. The graph has the same shape, but Matlab gives the same extreme values in positive and negative. SolidWorks does not. I expect different values (but i may be incorrect).
This is is the "original" matlab plot (array from kinematic calculations). It is an array of numerical values (from a for-loop). These look very similar,
Then I try to find the acceleration by taking the derivative of the speed-plot (or more accurate: the array).
Code:
dydx = gradient(array(:)) ./ gradient(t_span(:));
plot(t_span,dydx,'--')
Result:
As you can see, they look very similar, but the extreme values are different.
EDIT: the matlab plots have extreme values: -1202.42418329735, +1202.42418329735.
I use Matlab R2019b
I am a beginner user of Matlab.
In advance, thanks!
(my first post here. Please let me know if I need to change anything)

Réponses (1)

Juan Sagarduy
Juan Sagarduy le 25 Nov 2020
Hi Jörgen It looks like the kinematic motion in MATLAB is somehow idealized. The one from SolidWorks is asymmetric and thus shows a different acceleration. Is the result for MATLAB obtained with an imported CAD model with Simscape Multibody? Br Juan
  1 commentaire
Jørgen Tømmermo
Jørgen Tømmermo le 25 Nov 2020
Thanks for answering!
Okay. From looking at the velocity-plot i would assume the acceleration to be asymmetric. Nothing is imported to Matlab and no apps/tools are used other than programming a script. I will include the code if that helps to make things understandable.
The code first declares the dimentions of the mechanism. Then uses kinematic formulas to calculate the velocity in the point of interest (from knowing the rpm of the wheel and all dimentions).
A for-loop is used to create a data set that is finally plotted. These opearations seem okay until the gradient function is applied to the array.
Excuse the norwegian comments. I include them in case the units of measure helps to understand.
% Startverdi
w = -20 % definerer en vinkelhastigheten til skiva i [rpm]
w_1 = w*2*pi/60 % gjør om vinkelhastigheten til [rad/s]
r_1 = 45 % lengden fra senter av rotasjonen til sveiva [mm]
r_2 = 166 % lengden på armen [mm]
r_5 = 84 % lengden fra senter av rotasjonen til punktet A [mm]
i = 1;
t_span = 0:0.1:6 % tidsintervall
array = zeros(1,length(t_span)) % lager et datasett
for v = t_span
% Vinkel alfa 2
t = v % definerer en vilkårlig tid [s]
a_2r = w_1*t % vinkel alfa 2 [rad]
a_2d = a_2r*180/pi % gjør om vinkel alfa 2 fra radianer til grader
% Fart i punkt B
v_Bj = w_1*(r_1*cosd(a_2d)) % farten til punkt B i z-retning (+) siden k*i=j
v_Bi = -w_1*(r_1*sind(a_2d)) % farteb til punkt B i x-retning, (-) siden k*j=-i
v_B = sqrt(v_Bi.^2+v_Bj.^2) % absoluttveriden av farten B
% Vinkelhastighet i punkt A og den relative hastigheten til punkt B
x_1 = cosd(a_2d)*r_1 % avstanden i x-retning mellom punkt A og B
z_1 = (sind(a_2d)*r_1)+r_5 % avstanden i z-retning mellom punkt A og B
a_1d = atand(z_1/x_1) % vinkelen mellom punkt O og B ref. tegning i rapport
if x_1<0
a_1d = 90 + (90+a_1d)
end
% ender opp med følgende formel for vinkelhastighet og relativ hastighet:
% v_B=v_Brel*cos(α_1d)*i+v_Brel*sin(α_1d)*j+w_A*k*(x_1*i+z_2*j)
% formelen gir oss to ukjente med to likninger: i og j plan
% i: v_Bi=v_Brel*cos(a_1d)-w_A*z_1
% j: v_Bj=v_brel*sin(a_1d)+w_A*x_1
% det gir oss følgende matrise:
A_v = [cosd(a_1d) -z_1;sind(a_1d) x_1]
b_v = [v_Bi;v_Bj]
x_v = A_v\b_v
% x_v = [v_Brel; w_A]
v_Brel = x_v(1)
w_A = x_v(2)
% Farten i punktet C:
% v_c = w_A*r_2
%Farten til klossen D:
% v_d = v_ci
% v_ci: farten til punktet C i x-retning
% v_c = w_A*r_2 = w_A*k(x_2*i+z^2*j)
% v_ci = (w_A*k)*(z_2*j)
% v_cj = (w_A*k)*(x_2*i)
x_2 = cosd(a_1d)*r_2 % avstanden i x-retning mellom punkt A og C [mm]
z_2 = abs(sind(a_1d)*r_2) % avstanden i z-retning mellom punkt A og C [mm]
v_ci = -w_A*z_2 % farten til punktet C i x-retning (-) siden k*j=-i
v_cj = w_A*x_2 % farten til punktet C i z-retning (+) siden k*i=j
v_c = sqrt(v_ci.^2+v_cj.^2)
v_D = v_ci % farten til klossen [mm/s]
array(i) = v_D % datasett med alle verdiene ved et gitt tidsintervall for farten til klossen D
i = i + 1
end
plot(t_span, array,'red') % plotter grafen av farten til klossen
hold on
dydx = gradient(array(:)) ./ gradient(t_span(:));
plot(t_span,dydx,'--') % graf for akselerasjonen til klossen

Connectez-vous pour commenter.

Catégories

En savoir plus sur Time and Frequency Domain Analysis dans Help Center et File Exchange

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by