Dr. Arne JachensDr. Arne Jachens

php Library

polynominalFit

Keine Erläuterungen gefunden.

<?php
function polynominalFit($data,$order,$xCol,$yCol){
  /*
  ###########################################
  # you can pipe the output into file 'foo' #
  # and run 'gnuplot foo' in your shell     #
  ###########################################
  */
  $dim=count($data);
  for($i=0;$i<$dim;$i++){
    $dataString.=sprintf("%3.2e %4.3e \n",$data[$i][$xCol], $data[$i][$yCol]);
  } #i
  $abc=array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z");
  $formula="a";
  $variables="a";
  for($o=1;$o<=$order;$o++){
    $formula.="+".$abc[$o]."*x**".$o;
    $variables.=",".$abc[$o];
  }

  $plotCommand="f(x)=".$formula." \n";
  $plotCommand.="fit f(x) '-' u 1:2 via ".$variables." \n";
  $plotCommand.=$dataString." \n";
  $plotCommand.="end \n";
  $plotCommand.="set xrange [5:80] \n";
  $plotCommand.="set yrange [0.1e6:2e6] \n";
  $plotCommand.="set format y '%2.1e' \n";
  #$plotCommand.="set logscale y 10 \n";
  $plotCommand.="plot  '-',f(x) \n";
  $plotCommand.=$dataString." \n";
  $plotCommand.="end \n";
  $plotCommand.="pause -1";
  return $plotCommand;
}

Index of Library

1globals.php
2readData.php
3XML_readFile.php
4fraktal.php
5fileGrep.php
6XML_extractTag.php
7writeNamedData.php
8readXmlFile.php
9readNamedData.php
10XML_findAllElements.php
11readFromStdIn.php
12plotResult.php
13dtaus.php
14pdf.php
15fitData.php
16XML_extractElement.php
17readFilenames.php
18writeData.php
19genDTAUS.php
20closeFigures.php
21XML_extractAttribute.php
22enumerateFiles.php
23db.php
24polynominalFit.php
25LaTeXbrief.php
26hex2dec.php

Der gesamte Sourcecode darf gemäß GNU General Public License weiterverbreitet werden.