Matlab figure Matlab绘制着色区域

Matlab figure Matlab绘制着色区域,matlab-figure,Matlab Figure,我正在编写此代码以获得线性功耗结果: P_out = 0:100; Po= 130 ; dP= 4.7 ; N_TRX=6; P_max= 20; p_sleep= 75; if 0< P_out <= P_max P = N_TRX*Po+N_TRX*dP*P_out; else P=N_TRX* p_sleep; end %%%%% Po= 130 ; dP= 2.8 ; N_TRX

我正在编写此代码以获得线性功耗结果:

P_out = 0:100;   
Po= 130 ;         
dP= 4.7 ;         
N_TRX=6;
P_max= 20;
p_sleep= 75;

if 0< P_out <= P_max
    P = N_TRX*Po+N_TRX*dP*P_out;
else 
   P=N_TRX* p_sleep;
end
%%%%%
Po= 130 ;          
dP= 2.8 ;         
N_TRX=6;
P_max= 40;

if 0< P_out <= P_max
    P1= N_TRX*Po+N_TRX*dP*P_out;
else 
   P1=N_TRX* p_sleep;
end
%%%%%
Po= 130 ;          
dP= 5.9 ;         
N_TRX=2;
P_max= 20;

if 0< P_out <= P_max
    P2= N_TRX*(Po+dP*P_out);
else 
   P_in2=N_TRX* p_sleep;
end
%%%%%
Po= 110 ;          
dP= 4.2;         
N_TRX=6;
P_max= 20;

if 0< P_out <= P_max_macro
    P3= N_TRX*Po+N_TRX*dP*P_out;
else 
   P3=N_TRX* p_sleep;
end

figure, plot(P_out,P,'b'); hold on, plot(P_out,P1,'g'); hold on,      plot(P_out,P2,'r'); hold on,plot (P_out,P3,'y'),hold off
P_out=0:100;
Po=130;
dP=4.7;
N_TRX=6;
P_max=20;
p_睡眠=75;

如果0这里有一种使用
区域
功能的方法:

h = area(P_out,[P2;P1-P2;P3-P1;P-P3].');
h(1).FaceColor = 'r';
h(2).FaceColor = 'g';
h(3).FaceColor = 'y';
h(4).FaceColor = 'b';
这将为您提供以下信息:

您还可以使用更好的颜色和透明度:

ax = axes;
col = mat2cell(lines(4),ones(4,1),3);
hold on
h(1) = area(ax,P_out,P);
h(4) = area(ax,P_out,P3);
h(2) = area(ax,P_out,P1);
h(3) = area(ax,P_out,P2);
set(h,{'FaceColor'},col)
set(h,'FaceAlpha',0.6)
hold off
要获得此信息: