0

我想知道如何以polyarea不同的时间间隔在 MATLAB 中使用。例如,我有disp=[1,2,3,4,5.....]load = [3,4,5,6,7,8....]。我想polyarea(disp,load)每 40 行(或间隔)计算一次。disp 和 load 是循环加载和位移数据,包含 1000+ 行这样的数据。任何帮助深表感谢!

编辑 1:( 基于 m7913d 的回答)似乎代码没有给出适当的答案。代码有什么问题吗?

data=xlsread('RE.xlsx');
time=data(:,1);
load=data(:,2);
disp=data(:,3);
duration = 40;
n = length(disp); % number of captured samples
nCycles = floor(n/duration); % number of completed cycles
areas = zeros(nCycles, 1); % initialise output (area of each cycle)
for i=1:nCycles % loop over the cycles
    range = (i-1)*duration + (1:duration); % calculate the indexes corresponding with the ith cycle
    areas(i) = polyarea(disp(range), load(range)); % calculate the area of the ith cycle
end
4

1 回答 1

0

假设每个周期具有相同的已知持续时间 ( duration = 40),您可以按如下方式计算每个周期的面积:

duration = 40;
n = length(A); % number of captured samples
nCycles = floor(n/duration); % number of completed cycles
areas = zeros(nCycles, 1); % initialise output (area of each cycle)
for i=1:nCycles % loop over the cycles
    range = (i-1)*duration + (1:duration); % calculate the indexes corresponding with the ith cycle
    areas(i) = polyarea(A(range), B(range)); % calculate the area of the ith cycle
end

延伸阅读

由于这对我来说似乎是一个基本问题,因此查看MATLAB入门教程可能会很有用。

于 2017-06-26T19:26:55.730 回答