I want to draw composite of two trapezoidal MFs by Octave
. This is what I tried:
%MAX composite
pkg load linear-algebra
tx = ty = linspace (-10,10,100)';
cartesian_prod_domain = cartprod(tx,ty);
a = -6; b = -2; c = 2;d = 6;
trape_x = max(min(min(1, (cartesian_prod_domain(:,1) - a)/(b - a)), -(cartesian_prod_domain(:,1) - d)/(d - c) ),0);
trape_y = max(min(min(1, (cartesian_prod_domain(:,2) - a)/(b - a)), -(cartesian_prod_domain(:,2) - d)/(d - c) ),0);
cartesian_prod_range = (max([trape_x, trape_y]'))';
plot3 (cartesian_prod_domain(:,1), cartesian_prod_domain(:,2), cartesian_prod_range);
And this is what I got:
As you can see, it is wired; but I want to get something like this which has surface:
Probably it can be done by mesh
; but I could not. How I can get that?
The surf / mesh commands work on 'gridded' data. Try this instead:
a = -6; b = -2; c = 2; d = 6; Range = linspace( -10, 10, 100 );
[XGrid, YGrid] = ndgrid( Range, Range );
trape_x = max( min( min( 1, (XGrid - a) / (b - a) ), - (XGrid - d) /(d - c) ), 0 );
trape_y = max( min( min( 1, (YGrid - a) / (b - a) ), - (YGrid - d) /(d - c) ), 0 );
Zout = max( trape_x, trape_y );
surf( XGrid, YGrid, Zout );