1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
clear;clc
%Generate data
[H,C] = meshgrid(0:0.1:10);
NB=H+2*C;
% Get True where condition aplies, false where not.
cond1=-H+C<=3;
cond2=2*H+C<=28;
cond3=C<=8;
% Get boundaries of the condition
Cp1=3+H(1,:);
Cp2=28-2*H(1,:);
Cp3=8;
%Delete Areas whereCondition does not apply;
NB(~cond1)=NaN;
NB(~cond2)=NaN;
NB(~cond3)=NaN;
%% Plot
[C,h]=contourf(H,C,NB,20);
hold on
plot(H(1,:),Cp1,'r')
plot(H(1,:),Cp2,'k')
plot(H(1,:),ones(size(H(1,:))) * Cp3,'r')
axis([0 10 0 10])
xlabel('H, Hydropower')
ylabel('C, Crops') |
Partager