Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I draw this network of tubes in Matlab?
    primarykey
    data
    text
    <p><img src="https://i.stack.imgur.com/vExRQ.jpg" alt="enter image description here"></p> <p>I have a distribution of tube radius <code>r</code>, and I would like to plot tubes for all the sampled <code>r</code> in single figure as shown in the figure above. The tubes have following characteristics:</p> <ul> <li><p>The length of all tubes is constant, but radius is varying.</p></li> <li><p>The narrowest tube will be completely filled with light gray color. </p></li> <li><p>The length of the light gray color from bottom in all other tubes is inversely proportional to the radius of the tube i.e.</p> <p><code>length of light grey color from bottom = constant/r</code></p></li> <li><p>The remaining length of the tube will be filled with dark gray color.</p></li> <li><p>Magnitudes of <code>r</code> and total length of each tube is of the order of <code>1e-005</code>m and <code>1e-002</code> m, respectively, so they need to be standardized compared to the X and Y axes units.</p></li> <li><p>The white interspaces are just spaces and not tubes. </p></li> </ul> <p><strong>UPDATE (Based on the answer by Boris)</strong></p> <p>This is the code from Boris in which I made certain changes based on the characteristics of the tubes that I have described above. I am having scaling issues as I am not able to visualize my network of tubes as clearly as can be seen in the figure above.</p> <pre><code>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&gt;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 </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload