Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use strict;
- use warnings;
- use Chart::Gnuplot;
- # perque no funciona" sub f { shift**2 } "?
- sub f {
- my $x = shift;
- return $x ** 2
- }
- my @values = -10..10; #interval de 1
- # Per donar millor frequencia de mostreig de la senyal seria genial
- # que el operador .. tingues un tercer parametre, per exemple
- # my @values = -10..10|0.1 -10,-9.9,-9.8...9.8,9.9,10
- # contemplant possibles problemes amb els rangs.
- # Si no,s'hauria de fer la funcio que va sumant el 0.1 desde -10 fins a 10 i contemplant
- # els casos de truncament i les excepcions. O hi ha una altra manera?
- my @fvalues = map {f($_)} @values;
- my $chart = Chart::Gnuplot->new(
- output => "discretequadratic.png",
- title => "test",
- xlabel => "My x-axis label",
- ylabel => "My y-axis label",
- );
- # Create dataset object and specify the properties of the dataset
- my $dataSet = Chart::Gnuplot::DataSet->new(
- xdata => \@values,
- ydata => \@fvalues,
- style => "points",
- );
- # Plot the data set on the chart
- $chart->plot2d($dataSet);
Add Comment
Please, Sign In to add comment