簡體   English   中英

如何在Matlab中繪制此管網?

[英]How can I draw this network of tubes in Matlab?

在此處輸入圖片說明

我具有管半徑r的分布,並且我想在單個圖中繪制所有采樣r管,如上圖所示。 這些管具有以下特征:

  • 所有管的長度是恆定的,但是半徑是變化的。

  • 最窄的管將完全充滿淺灰色。

  • 在所有其他管中,淺灰色從底部開始的長度與管的半徑成反比,即

    length of light grey color from bottom = constant/r

  • 管的剩余長度將用深灰色填充。

  • r大小和每根管的總長度分別約為1e-005 m和1e-002 m,因此與X和Y軸單位相比,它們需要進行標准化。

  • 白色的間隙只是空間,而不是管。

更新(基於鮑里斯的答案)

這是鮑里斯(Boris)編寫的代碼,在該代碼中,我根據上述管的特性進行了某些更改。 我遇到縮放問題,因為我無法如上圖所示清晰地可視化我的管網。

function drawGrayTube (x, r, sigma_wn, theta, del_rho, rmin, rmax,L)
% sigma_wn is in N/m (=Kg/s^2), theta is in degrees, del_rho is in Kg/m^3
% and L is in m
h=((2*sigma_wn*cos((pi/180)*theta))./(del_rho*9.81.*r));
hmin=((2*sigma_wn*cos((pi/180)*theta))./(del_rho*9.81.*rmax));
hmax=((2*sigma_wn*cos((pi/180)*theta))./(del_rho*9.81.*rmin));

rectangle ('Position',[x,0,r/rmax,h], 'FaceColor',[0.7,0.7,0.7]);
ylim([0 1]);

if L>h
    rectangle ('Position',[x,L,r/rmax,L-h], 'FaceColor',[0.3,0.3,0.3]);
    ylim([0 1]);
else
    rectangle ('Position',[x,L,r/rmax,L], 'FaceColor',[0.3,0.3,0.3]);
    ylim([0 1]);
end

end

例如,繪制灰管的簡單功能可能是

function drawGrayTube (x, w, h)
    rectangle ('Position',[x,0,w,h], 'FaceColor',[0.7,0.7,0.7]);
    rectangle ('Position',[x,h,w,100-h], 'FaceColor',[0.3,0.3,0.3]);
end

因此, x是管的x位置, w表示寬度, h表示管的淺灰色部分的高度,介於0100之間。

您現在可以在示例中使用它,方法是調用

drawGrayTube (x, r, 100*constant/r)

您必須調整常數,使得constant/r最多為1

您可以為白色間隔編寫類似的函數。

假設您已經給定了一個半徑矢量(已經縮放,使得值在0到1之間),例如r=[0.5, 0.7, 0.9, 0.1, 0.5, 0.01]那么繪制管的可能性是

interspace = 0.5;
for i=1:length(r)
    drawGrayTube(sum(r(1:i-1))+i*interspace, 100*r(i)+1e-10, r(i)+1e-10); 
end

您應該使用rectangle函數

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM