필터 지우기
필터 지우기

How can I fill the area between a function and the vertical axis x = 0, either for positive or negative values of it?

조회 수: 3 (최근 30일)

I have several diagrams which plot one function. I want to fill an area between that function (lineal, curve..)and a the vertical axis x = 0. So, how can I fill the area, either for positive or negative values of it?

The function is a piecewise function. The code of one case is:

 y_B1 = 0:0.01:h_poste;
        Mz_B1 = -((y_B1<=h_hc).*(R_Mz_v1_B+R_Vx_B1.*y_B1+((1/2).*y_B1.*y_B1*(Qwstr1/h_poste)*(1/3).*y_B1))+((y_B1>h_hc)&(y_B1<=h_CdPa)).*(R_Mz_v1_B+R_Vx_B1.*y_B1+((1/2).*y_B1.*y_B1*(Qwstr1/h_poste)*(1/3).*y_B1)+M_hc+(Esf_rad_hc+Qwc(1)).*(y_B1-(h_hc+ht)))+((y_B1>h_CdPa)&(y_B1<=cdg_mensula_y)).*(R_Mz_v1_B+R_Vx_B1.*y_B1+((1/2).*y_B1.*y_B1*(Qwstr1/h_poste)*(1/3).*y_B1)+M_hc+(Esf_rad_hc+Qwc(1)).*(y_B1-(h_hc+ht))+M_CdPa+(Esf_rad_CdPa_B+Qwc(3)).*(y_B1-(h_CdPa)))+((y_B1>cdg_mensula_y)&(y_B1<=h_sust)).*(R_Mz_v1_B+R_Vx_B1.*y_B1+((1/2).*y_B1*(Qwstr1/h_poste)*(1/3).*y_B1)+M_hc+(Esf_rad_hc+Qwc(1)).*(y_B1-(h_hc+ht))+M_CdPa+(Esf_rad_CdPa_B+Qwc(3)).*(y_B1-(h_CdPa))+M_mensula)+((y_B1>h_sust)&(y_B1<=h_Feed)).*(R_Mz_v1_B+R_Vx_B1.*y_B1+((1/2).*y_B1.*y_B1*(Qwstr1/h_poste)*(1/3).*y_B1)+M_hc+(Esf_rad_hc+Qwc(1)).*(y_B1-(h_hc+ht))+M_CdPa+(Esf_rad_CdPa_B+Qwc(3)).*(y_B1-(h_CdPa))+M_mensula+M_sust+(Esf_rad_sust+Qwc(2)).*(y_B1-(h_sust+ht)))+((y_B1>h_Feed)&(y_B1<=h_poste)).*(R_Mz_v1_B+R_Vx_B1.*y_B1+((1/2).*y_B1.*y_B1*(Qwstr1/h_poste)*(1/3).*y_B1)+M_hc+(Esf_rad_hc+Qwc(1)).*(y_B1-(h_hc+ht))+M_CdPa+(Esf_rad_CdPa_B+Qwc(3)).*(y_B1-(h_CdPa))+M_mensula+M_sust+(Esf_rad_sust+Qwc(2)).*(y_B1-(h_sust+ht))+M_Feed+(Esf_rad_Feed_B+Qwc(4)).*(y_B1-(h_Feed))));
        figure
        ley_Mz_B1 = plot(Mz_B1,y_B1);grid;
        title('CASO DE CARGA B (Viento 1).Ley de esfuerzos flectores')
        xlabel('Momento flector Mz (N·m)');
        ylabel('Altura (m)');

where Mz_B1 is the function represented and y_B1 is the vector of independent values.

NOTE: the black area has been made using Paint.

채택된 답변

Mike Garrity
Mike Garrity 2016년 3월 17일
This post I did on the MATLAB Graphics blog might give you some ideas on how to do this.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by