How to find a surface area for any plotted wave

Hi all, I am doing a project which involves plotting peaks values in a waveform and finding the surface area. I m done with plotting, can anyone give me the idea of how to find a surface area for any waveform.

 채택된 답변

Paulo Silva
Paulo Silva 2011년 3월 10일

1 개 추천

doc trapz
doc cumtrapz

댓글 수: 22

santosh
santosh 2011년 3월 10일
Thanks for ur help,
I have tried with different wave forms but i m getting the same result. Can u pls help me
Paulo Silva
Paulo Silva 2011년 3월 10일
You have the sampling frequency (Fs) of the wav, time values (X) and amplitude of the wav (Y), you just need to calculate:
trapz(X,Y)/Fs
santosh
santosh 2011년 3월 10일
thanks for ur prompt reply paulo,
I dont have sampling frequency for each wave, I just have time and amplitude. Is it possible to get without the frequency or if no, then pls help me out to find the sampling frequency for each wave I choose.
Paulo Silva
Paulo Silva 2011년 3월 10일
Fs=1/(t(ind+1)-t(ind))
santosh
santosh 2011년 3월 10일
thnx paulo
I used the above function but it is showing me the error as
??? Error using ==> mrdivide
Matrix dimensions must agree.
Error in ==> trialdiff45matrix at 216
Z = cumtrapz(t(record2),1)/Fs;
Here is the figure code which i m using to plot and i trying to find the surface area of that wave, I used the matrices to plot this wave may be this is causing me the error. Pls have a look on this code
figure(7);
plot(t,Z2,t(record2),Z2(record2),'r*');
title('Averaged desired points found through Absolute Difference matrix');
Fs=1/(t(record2+1)-t(record2))
Z = trapz(t(record2),Z2(record2))/Fs
Paulo Silva
Paulo Silva 2011년 3월 11일
insert a . before / so the operations can be done element by element, I'm not sure about what your are doing. Fs should be a single value not a vector but with luck it could work.
Paulo Silva
Paulo Silva 2011년 3월 11일
Just in case you got different Fs values in a time vector (t) and you want to know the values do this:
unique(1./diff(t))
santosh
santosh 2011년 3월 11일
pls have a look on ur mail paulo I sent u the code and input file as well
Paulo Silva
Paulo Silva 2011년 3월 11일
I'm very sorry but I just can't help everyone that sends me emails, everyday someone sends their homework to my email but I have my own important things to do and the time spent here is already too much, it's better for you to put your questions and doubts here for all to see!
santosh
santosh 2011년 3월 11일
hello,
sorry for the mail.
I have large number of input files which consists of data in CSV format. Each data file has about 600 rows and 2 columns. So i want to find the surface area under the curve for each file after plotting. can u plz help me out.
Paulo Silva
Paulo Silva 2011년 3월 11일
The way I told you to calculate Fs, does it return one value of Fs for a given file data?
santosh
santosh 2011년 3월 11일
No, actually it is returning more values.
Paulo Silva
Paulo Silva 2011년 3월 11일
are the values very similar, if so average them and use that value for Fs
santosh
santosh 2011년 3월 11일
I tried taking average and i got one value. but getting same value for different data files
Paulo Silva
Paulo Silva 2011년 3월 11일
that means that all measurements used the same Fs don't you agree?
santosh
santosh 2011년 3월 11일
No all the measurments have variations even the surface area calculation:
Fs=1/(t(record2+1)-t(record2));
Q= mean(Fs);
Z = trapz(t(record2),Z2(record2))/Q;
for above variables the values are same for different measurments.
Paulo Silva
Paulo Silva 2011년 3월 11일
what's record2?
santosh
santosh 2011년 3월 11일
record2 is an index which contains time and voltage values
Paulo Silva
Paulo Silva 2011년 3월 11일
Try with cumtrapz
Fs=1/(t(record2+1)-t(record2));
Q= mean(Fs);
Z = cumtrapz(t(record2),Z2(record2))/Q;
santosh
santosh 2011년 3월 11일
I m getting the following output as
Z =
1.0e-010 *
0
-0.0102
-0.3311
-0.3460
-0.3568
-0.3329
0.0241
0.0460
>> Fs
Fs =
1.0e+006 *
0 0 0 0 0 0 0 5.0000
the above result is same for all the data files.
Paulo Silva
Paulo Silva 2011년 3월 11일
there's something wrong with your code, please check it, it's too late here, must go sleep a bit, good luck finding the error, bye
santosh
santosh 2011년 3월 11일
thnx alot for ur answers i will work out and catch u tomorrow gud nt.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Graphics Performance에 대해 자세히 알아보기

태그

질문:

2011년 3월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by