10 views (last 30 days)

Hello,

Could you please guide me how to calculate the area of the green shaded region (between blue and red curve) of the attached figure in MATLAB. Please see the attached pic named "how to calculate area".

Blue line has the value of 1 p.u and is a straight horizontal line.

Thanks

Image Analyst
on 30 Jan 2015

Image Analyst
on 30 Jan 2015

Where did you post the "more zoomed in view"? Can't you just use quad()? Or even polyarea()???

Niels
on 2 Feb 2015

Edited: Niels
on 2 Feb 2015

Is it not possible to simply calculate the difference between your y-values and the straight line, take the mean of every 2 neigboring y-values, then multiply those values by your x-spacing and then sum all the values between x = 2166 and x = 5590? ie.

spc = 1; % spacing of x-values

x = 1:spc:20; % full x-range

x_min = 5; % lower boundary of interest

x_max = 12; % upper boundary of interest

y = 30-0.5*x + rand(1,numel(x)); % y-values for full x-range

y_ref = 30; % reference value for y

y_means = mean([y(1:end-1); y(2:end)],1) - y_ref;

y_range = y_means(x(x==x_min):x(x==x_max-1));

y_int = sum(y_range*spc);

Or more simple:

y_int = trapz(x_min:x_max,y(x_min:x_max));

Opportunities for recent engineering grads.

Apply Today
## 0 Comments

Sign in to comment.