# how to find area under curve for every 10msec?

조회 수: 3(최근 30일)
Keshasni Earichappan 2021년 8월 11일
편집: Scott MacKenzie 2021년 8월 15일
Hi, i have tried finding area under curve for each parabolic curve or for every 10msec time (as shown in the figure) but i coudn't find it.I only can find the whole area under curve of the graph by using the code as i attached. How to find area under curve for every 10msec time and plot them as a graph.Hope someone can help me with this.Thank you in advance.
t = T1.('TIME'); v = T1.('TORQUE');
plot(t,v)
grid
xlabel('t')
ylabel('v')
title('TORQUE VS TIME')
hold on;
Area=trapz(t,v);
plot(Area)
openfig('torque vs time.fig');

댓글을 달려면 로그인하십시오.

### 채택된 답변

Scott MacKenzie 2021년 8월 13일
편집: Scott MacKenzie 2021년 8월 15일
Here's solution that shows the slope (derivative) and area (integral) sample-to-sample in the signal. The sample period is 10 ms. For illustration, there are plots for the entire signal and for just the first 300 samples of the signal.
time = M(:,3);
torque = M(:,4);
Ps = mean(diff(time)); % sample period
% slope, sample to sample
s = diff(torque) / Ps; % slope = dy/dz
s = [0 s'];
tiledlayout(3,2);
% all samples
nexttile(1);
plot(time, torque); % signal
title('All samples');
nexttile(3);
plot(time, s); % slope (sample to sample)
title('diff (slope)');
nexttile(5);
tqa1 = (torque(1:end-1) + torque(2:end)) / 2 * Ps; % area under (sample to sample)
tqa1 = [0; tqa1];
plot(time, tqa1);
title('area under (10-ms intervals)');
% 1st 300 samples
m = 300;
nexttile(2);
plot(time(1:m),torque(1:m)); % signal
title('First 300 samples');
nexttile(4);
plot(time(1:m),s(1:m)); % slope (sample to sample)
title('diff (slope)');
nexttile(6);
tqa2 = (torque(1:m-1) + torque(2:m)) / 2 * Ps; % area under (sample to sample)
tqa2 = [0; tqa2];
plot(time(1:m),tqa2);
title('area under (10-ms intervals)');

댓글을 달려면 로그인하십시오.

### 범주

Find more on Chebyshev in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by