【问题标题】:Converting force into displacement by using cumtrapz [closed]使用 cumtrapz 将力转换为位移 [关闭]
【发布时间】:2018-02-02 08:31:35
【问题描述】:

我需要将力数组转换为位移数组。我编写了这段代码,但我得到的位移值有问题,因为它们比我预期的要高得多。

clc;
clear;

log = dlmread('testThumb.csv');
time = log(:,1);
force = log(:,2)./1000;   #Converting from mN to N  


time = time(2:2904);           
force = force(2:2904);

force= detrend(force);

ace = force/0.0575;       #I get the acceleration by dividing the force between the mass

speed = cumtrapz(time,ace);           #Integration of the aceleration

position = cumtrapz(time,speed) * 1000;     #Integration of the speed and 
conversion of the speed from meters to millimeters

figure(1);

subplot(211);
plot(time,speed);                       #Speed in m/s, time in seconds
subplot(212);
plot(time,position);                    #Position in millimeters, time in seconds

样本之间的时间为 0.05,力是拇指通过某些动作产生的力,该值永远不会高于 20 牛顿。

这些是我得到的结果

谁能解释我得到的价值观?

【问题讨论】:

    标签: matlab math octave


    【解决方案1】:

    我认为问题与积分时的初始条件有关。我没有你的数据,但考虑一下这个虚拟数据(我使用三角函数来更容易计算导数):

    t = 0:0.05:10; % Time [s]
    x = sin(2*pi*t); % Displacement [m]
    xdot = 2*pi*cos(2*pi*t); % Speed [m/s]
    xddot = -(2*pi)^2*sin(2*pi*t) % Acceleration [m/s^2]
    

    如果我现在尝试在不关注初始条件的情况下将加速度与cumntrapz 集成并将其与我的速度曲线进行比较,我会得到:

    spd = cumtrapz(t,xddot);
    plot(t,xdot,t,spd)
    xlabel('Time [s]')
    ylabel('Speed [m/s]')
    grid on
    legend('Speed','Integrated acceleration')
    

    注意到速度曲线和综合加速度之间的偏移了吗?那是因为初始条件。当您再积分一次以获得位移时,问题变得更加复杂:

    disp = cumtrapz(t,spd);
    plot(t,x,t,disp)
    xlabel('Time [s]')
    ylabel('Displacement [m]')
    grid on
    legend('Displacement','x2 integrated acceleration')
    

    所以回答你的问题:找出你的速度和位移的初始条件,并相应地调整来自cumtrapz 的积分结果以获得合理的结果。

    【讨论】:

      猜你喜欢
      • 2021-11-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-23
      • 2012-06-13
      • 1970-01-01
      • 2010-09-08
      相关资源
      最近更新 更多