How to get only those output values which lie under a given curve!

3 次查看(过去 30 天)
Hi everyone, I have a graph with tabulated values (x1-xn, y1-yn and z1-zn). I used interpolation to get required values of 'Z' w.r.t x and y. However i also need to use only those values of Z which lie under a given line ( limiting curve ) having four coordinates ( as mentioned in fig). I don't have any equation for this line then how can i make sure my output value always remain under this given curve or satisfy this condition!
TiA for all the good work you do!
regards

采纳的回答

Shoaibur Rahman
Shoaibur Rahman 2014-12-24
Perhaps, you unconsciously mistyped the x coordinate of third point. I use 3800 instead of 2100, but use what the actual value is. Also, I use random Z data here for test purposes.
x = 1000:4500;
z = 11+randn(1,length(x)); % use the data that you got
plot(x,z,'om'), hold on
x1 = 1000:2100;
y1 = 8+(8-13.2)/(1000-2100)*(x1-1000); % first boundary, straight line equation
z1 = z(1:length(y1)); % z values in the given range x1
z1(z1 >= y1) = NaN; % discard z values that are above the boundary
plot(x1,y1,'r'), plot(x1,z1,'o','MarkerSize',12)
x2 = 2100:3800;
y2 = 13.2+(13.2-14.6)/(2100-3800)*(x2-2100); % second boundary
z2 = z(length(y1)+1:length(y1)+length(y2)); % z values in the given range x2
z2(z2 >= y2) = NaN; % discard z values that are above the boundary
plot(x2,y2,'r'), plot(x2,z2,'o','MarkerSize',12)
x3 = 3800:4500;
y3 = 14.6+(14.6-12)/(3800-4500)*(x3-3800); % third boundary
z3 = z(length(y1)+length(y2)-1:end); % remaining z values
z3(z3 >= y3) = NaN; % discard z values that are above the boundary
plot(x3,y3,'r'), plot(x3,z3,'o','MarkerSize',12)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by