maybe you could consider putting the radii and the cross sections in the same array as they seem to belong together.
#!/usr/bin/perl -w
# loop over drop radius from 1 micron to 100 microns in steps of 2 microns
# use each radius ($r) to compute cross section
# if r < 20 microns, use (pi)*(r^2)*a*(1-exp(-c*r))
# if r >= 20 microns, use 2*pi*(r^2)
use strict;
use Data::Dumper;
my @cross_sections = ();
my ($pi, $a, $c) = (atan2(0, -1), 1.18, 0.28e6);
for (my $i = 1 ; $i < 100; $i += 2) {
my $r = $i / 1000000;
if ($i < 20) {
push @cross_sections, [$r, $pi * $r**2 * $a * (1 - exp(-$c * $r))];
} else {
push @cross_sections,[$r, 2 * $pi * $r**2];
}
}
print Dumper(\@cross_sections);
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.