Advertisement
overloop

excel linear 2d interpolation with data incapsulation demo

Apr 7th, 2013
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.41 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. my $ip_preg = 'interp\(([^;]+);([^;]+);([^;]+);([^;]+);([^;]+)\)';
  4. my $ip_repl = '"И($1>=$2;$1<$3)*(($1-$2)/($3-$2)*($5-$4)+$4)"';
  5.  
  6. my @xi = (1,2,2,3,3,4);
  7. my @yi = (0,0,1,3,3,2);
  8. my $exp = '';
  9.  
  10. for (my $i = 0; $i < 6; $i += 2) {
  11.         $exp = $exp . "interp(A1;" . $xi[$i] . ';' . $xi[$i+1] . ';' . $yi[$i] . ';' . $yi[$i+1] . ')+';
  12.  
  13. }
  14.  
  15. $exp =~ s/$ip_preg/$ip_repl/gee;
  16. print $exp;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement