How to calculate Area under a curve

1 Ansicht (letzte 30 Tage)
Ahmed
Ahmed am 19 Dez. 2019
Beantwortet: Elnaz Ensafi am 31 Jul. 2020
Hello All,
I am trying to calculate shaded area of my x and y data given in the excel sheet. I am using the following code which calculates the entire area, but I want to subtract the un-shaded area from.
x = xlsread('filename','A:A');
y = xlsread('filename','B:B')
Integral = trapz(x,y);
area(x, y);
;
Is there anyone help me with the correct code please ?. Your response will be appreciated too much.

Akzeptierte Antwort

Star Strider
Star Strider am 19 Dez. 2019
Try this to get the integral only between 20 and 40:
lims = (x >= 20) & (x <= 40);
Integral = trapz(x(lims),y(lims));
  2 Kommentare
Ahmed
Ahmed am 19 Dez. 2019
Thanks a lot, truly appreciate it
Star Strider
Star Strider am 19 Dez. 2019
As always, my pleasure!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Elnaz Ensafi
Elnaz Ensafi am 31 Jul. 2020
I have plot that I extracted from EEG data. I would like to extract area under the curve from 25 ms to 275 ms. could you Please help me in this case?

Kategorien

Mehr zu EEG/MEG/ECoG finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by