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.

 Accepted Answer

doc trapz
doc cumtrapz

22 Comments

Thanks for ur help,
I have tried with different wave forms but i m getting the same result. Can u pls help me
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
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.
Fs=1/(t(ind+1)-t(ind))
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
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.
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))
pls have a look on ur mail paulo I sent u the code and input file as well
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!
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.
The way I told you to calculate Fs, does it return one value of Fs for a given file data?
No, actually it is returning more values.
are the values very similar, if so average them and use that value for Fs
I tried taking average and i got one value. but getting same value for different data files
that means that all measurements used the same Fs don't you agree?
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.
record2 is an index which contains time and voltage values
Try with cumtrapz
Fs=1/(t(record2+1)-t(record2));
Q= mean(Fs);
Z = cumtrapz(t(record2),Z2(record2))/Q;
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.
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
thnx alot for ur answers i will work out and catch u tomorrow gud nt.

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!