how can i Calculate area of plotted data using trapz in matlab?

조회 수: 1 (최근 30일)
have data from csv file. i want to calculate area under plot using trapz but im not sure if trapz is calculating from zero on y-axis as a reference or the starting point of x&y-axes. How can i calculate this area subtracting region below minimum point?
code is below data=csvread('test_1.csv'); new_data=smoothdata(data); x_col1=new_data(:,1); y_col2=new_data(:,2); figure('Name','Smoothed_waveform') plot(x_col1,y_col2,'r')
title('Induced emf') xlabel('Time (s)') ylabel('Amplitude')
grid on grid minor
max_y= max(new_data(:,2))% maximum value of signal min_y= min(new_data(:,2))% minimum value of signal amplitude= (max_y-min_y) %amplitude of signal area_2 = trapz(new_data(:,1),new_data(:,2))
graph

채택된 답변

Dimitris Kalogiros
Dimitris Kalogiros 2018년 9월 16일
편집: Dimitris Kalogiros 2018년 9월 16일
Before using trapz, do the following
new_data(:,2)=new_data(:,2)-min(new_data(:,2));
this shifts all of your graph upwards, so minimum value would be on xx' axis.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by